Add H3 + H4 dealloc edge-case hooks and integration test (Phase 3.4) - #9
Merged
Merged
Conversation
- Install H3 heap-profile hook in Allocator::dealloc_remote on the SecondaryAllocator branch (catches GWP-ASan / non-snmalloc pointers that bypass the snmalloc-owned pagemap). - Install H4 heap-profile hook in Allocator::dealloc_remote_slow's lazy-init recursion lambda, immediately before the recursive a->dealloc(p). Pairs with H1 to keep the recursion-guard tight. - Both hooks live entirely under #ifdef SNMALLOC_PROFILE; default Config OFF build is byte-identical to Phase 3.3. - Both hooks reuse profile::record_dealloc<Config>; idempotence is guaranteed by the CAS in clear_profile_slot and the per-thread ReentrancyGuard. No new state machines, no new allocations on the free path. - New test: src/test/func/profile_h3_h4/profile_h3_h4.cc. Triple- and quadruple-clear idempotence, nullptr robustness, fresh-thread remote-free stress, default-Config compile-time no-op. - New test: src/test/func/profile_integration/profile_integration.cc. 16 threads x 100k allocs x varied size ladder, ~50/50 same-thread vs cross-thread free, plus a one-producer-many-consumers stress. Asserts sample count within 6 sigma of Poisson expectation, post-free leak <= documented tolerance (<= 1% + 4), and that the global SampledList drains to zero. Sampling rate (128 KiB) sized so expected samples stay well below the NodePool capacity ceiling. - Wires ticket 86ahrfx9g (multi-threaded alloc + cross-thread dealloc integration stress). - Observed teardown-straggler ratio improves from ~1/1250 in the Phase 3.3 8-thread e2e test to ~1/4000 in the new 16-thread integration test, a ~3x reduction.
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.
Summary
Phase 3.4 — closes dealloc-side coverage. Completes the milestone's H1–H4 hook set.
corealloc.h:1458—Allocator::dealloc_remoteSecondaryAllocator escape arm. Catches GWP-ASan / non-snmalloc pointers that bypass the snmalloc-owned pagemap.corealloc.h:1522—Allocator::dealloc_remote_slowlazy-init recursion lambda, immediately before recursivea->dealloc(p). Pairs with H1 for tight recursion-guard.#ifdef SNMALLOC_PROFILE. Default Config OFF build byte-identical to Phase 3.3.record_dealloc<Config>. Idempotence guaranteed byclear_profile_slotCAS +ReentrancyGuard. No new state machines.Test plan
SNMALLOC_PROFILE=OFFSNMALLOC_PROFILE=ONprofile_h3_h4: triple/quadruple-clear idempotence, nullptr robustness, fresh-thread remote-free stress, default-Config compile-time no-opprofile_integration(ticket 86ahrfx9g): 16 threads × 100k allocs × {16,64,256,1024} size ladder, ~50/50 same/cross-thread free + one-producer-many-consumers stressSampledListdrains to zeroTickets closed: 86ahzwj2f (H3 + H4), 86ahrfx9g (multi-threaded alloc + cross-thread dealloc integration)