Repository navigation
[MOD-18996] Transfer allocation accounting between allocators - #1115
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
alexd-redis
approved these changes
Nov 12, 2026
Comment on lines
+19
to
+20
| auto source = VecSimAllocator::newVecsimAllocator(); | ||
| auto destination = VecSimAllocator::newVecsimAllocator(); |
Collaborator
There was a problem hiding this comment.
nit: const auto for both source and destination on all tests.
|
Successfully created backport PR for |
Merged
1 of 2 tasks
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
VecSimAllocator::transferAllocationToso 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::transferAllocationToso 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_transferis wired intotests/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.