Skip to content

[MOD-18996] Transfer allocation accounting between allocators - #1115

Merged
GuyAv46 merged 1 commit into
mainfrom
guy/mod-18996-allocation-transfer
Nov 12, 2026
Merged

GuyAv46 merged 1 commit into
mainfrom
guy/mod-18996-allocation-transfer

Conversation

@GuyAv46

@GuyAv46 GuyAv46 commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Add VecSimAllocator::transferAllocationTo so an owned allocation can move between allocator accounting domains without allocating, copying, or freeing memory. The transfer reads the complete charged size from the allocation header, preserving alignment and padding. The caller must exclusively own the allocation and update its deleter to the destination allocator; the two counters are not updated atomically as a pair.

Tests cover unaligned/aligned and zero-sized allocations, null/self transfers, transferring back, freeing after the source allocator is destroyed, preserved contents/alignment, balanced accounting, and zero allocation/free callbacks during transfer.

Validation: all three dedicated tests pass under ASan/UBSan with leak checking; changed C++ files pass clang-format and git diff --check. The tests were built directly with the allocator implementation and GoogleTest; the new CMake target is registered for CI.


Note

Medium Risk
Touches core allocator bookkeeping used for memory limits and tiered layers; incorrect caller use could double-count or leak accounting, though the change is localized and well-tested.

Overview
Adds VecSimAllocator::transferAllocationTo so an existing block can move between allocator accounting domains without malloc, memcpy, or free—the charged bytes (payload + header) are debited from the source and credited to the destination while the pointer, payload, and alignment stay the same.

Null pointers and self-transfers are no-ops. Callers must still rebind ownership (e.g. deleters) before freeing through the destination; the header documents that the two counters are not updated as one atomic pair.

A dedicated unit target test_allocation_transfer is wired into tests/unit/CMakeLists.txt, with tests for aligned/unaligned and zero-sized allocations, bidirectional transfers, accounting balance, preserved contents/alignment after the source allocator is dropped, and no underlying alloc/free during transfer.

Reviewed by Cursor Bugbot for commit 29518dd. Bugbot is set up for automated code reviews on this repo. Configure here.

@codecov

codecov Bot commented Nov 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.54%. Comparing base (001f0b0) to head (29518dd).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1115      +/-   ##
==========================================
+ Coverage   97.39%   97.54%   +0.14%     
==========================================
  Files         145      157      +12     
  Lines        9575    10019     +444     
==========================================
+ Hits         9326     9773     +447     
+ Misses        249      246       -3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@alexd-redis alexd-redis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

Comment on lines +19 to +20
auto source = VecSimAllocator::newVecsimAllocator();
auto destination = VecSimAllocator::newVecsimAllocator();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: const auto for both source and destination on all tests.

@GuyAv46
GuyAv46 added this pull request to the merge queue Nov 12, 2026
Merged via the queue into main with commit eefc4e7 Nov 12, 2026
18 checks passed
@GuyAv46
GuyAv46 deleted the guy/mod-18996-allocation-transfer branch November 12, 2026 12:31
@github-actions

Copy link
Copy Markdown

Successfully created backport PR for 8.8:

GuyAv46 added a commit that referenced this pull request Nov 12, 2026
* [MOD-18996] Transfer allocation accounting between allocators (#1115)

* Add Ubuntu 26.04 install script for the ubuntu-latest runner (#1111)

Add Ubuntu 26.04 install script for the new ubuntu-latest runner

GitHub's ubuntu-latest image moved to Ubuntu 26.04, and install_script.sh
failed with "ubuntu_26.04.sh: No such file or directory".

apt.llvm.org has no LLVM 18 repo for 26.04 (resolute), so install
clang-format-18 from the Ubuntu archive and point the unversioned
clang-format used by check-format.sh at it.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: dor-forer <dor.forer@redis.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport 8.8 Backport to 8.8

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants