Repository navigation
feat: add freelist prefix close and frame-pointer stack walker - #912
Draft
Jaya Kasa (jayakasadev) wants to merge 1 commit into
Draft
Jaya Kasa (jayakasadev) wants to merge 1 commit into
Jaya Kasa (jayakasadev) wants to merge 1 commit into
Conversation
Add two standalone primitives needed by refill-boundary heap profiling, with zero change to existing allocation or deallocation paths: - freelist::Builder::close_prefix() and count() (mem/freelist.h) to close at most N entries from a slab free-queue builder while retaining the remainder - Frame-pointer stack walker (pal/pal_stack_walker.h, included from pal/pal.h) for x86_64/aarch64 on Linux/macOS with PAC stripping and stack-bounds checks, plus a NullStackWalker fallback elsewhere - Unit test (freelist_prefix) and microbenchmark (stack_walker_bench)
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.
What
Adds two standalone primitives for heap profiling (#853), not yet wired into
mallocorfree:freelist::Builder::close_prefix()andcount()(src/snmalloc/mem/freelist.h) to hand out at mostNentries from a slab free-queue builder while keeping the rest.src/snmalloc/pal/pal_stack_walker.h) for Linux/macOS on x86_64 and aarch64 (with PAC stripping and stack-bounds checks), and a no-op fallback elsewhere.Why
Refill-boundary heap profiling trims a slab refill to the exact number of objects before the next sample and captures the caller's stack on sampled allocations. Landing these primitives first keeps the later profiler PRs small and easy to review.
Cost
Zero runtime cost on existing builds: neither
close_prefix()norstack_walk()is called by the allocator yet.Builder::close()resets tracked length only whenTRACK_LENGTHis enabled.Test plan
Run on macOS arm64 (
670ab11):DebugCMake (-fast+-check):ctest -j892/92 passed (including newfreelist_prefixtest andstack_walker_bench)ReleaseCMake (-fast+-check):ctest -j892/92 passedclang-format 15.0.7 --dry-run -Werrorclean