feat: alloc profile analyzer (top_alloc_types/leaves/frames + report) - #12
Merged
Conversation
Replays HBJ#8 onto main. Originally merged into chore/github-alignment 4 minutes after that branch had already been squash-collapsed into main (HBJ#10) — the merge commit afca64c is therefore orphaned on a stale branch and src/analyze.jl never made it to main. Same content as HBJ#8 (no changes), regenerated by `git apply`-ing the diff between origin/main and origin/chore/github-alignment. Aggregation helpers for AllocProfileResult that previously lived as a DTO-local script (DirectTrajOpt.jl#71 benchmark/analyze_allocs.jl) but are general-purpose and belong next to benchmark_memory! here in HBJ. - top_alloc_types(profile; k=15) — by allocated type - top_alloc_leaves(profile; k=25) — by first non-noise/non-wrapper frame (the user-code call site) - top_alloc_frames(profile; k=25) — by every frame in every sample's stacktrace - report_alloc_profile(profile) — pretty-printer that calls all three Built-in noise patterns drop Julia runtime / GC / Profile.Allocs / loader frames; built-in HBJ-wrapper patterns drop benchmark_memory! and package-internal frames so leaf views show actual user code. Both sets are extensible via extra_noise / extra_wrappers kwargs. Also adds Printf to [deps] / [compat] (was implicitly loaded but not declared).
3 tasks
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
Re-lands the alloc profile analyzer on
main. HBJ#8 was merged at2026-05-20T06:54:09Z into
chore/github-alignment— but HBJ#10(
chore/github-alignment→main) had been squash-merged 4 minutesearlier, so #8 landed on an already-orphaned branch.
src/analyze.jlnever reached
main; merge commitafca64cis stranded on the stalechore/github-alignmentbranch.This PR replays the exact same content onto a fresh branch off
current
main. Diff is byte-for-byte equivalent to HBJ#8 (verifiedvia
git diff origin/main origin/chore/github-alignmentover the fourtouched files).
What's in the PR (same as HBJ#8)
Three query functions return
Vector{AllocFrameSummary}sorted byallocated bytes, with optional
1 / sample_rateextrapolation:top_alloc_types(profile; k=15)— by allocated typetop_alloc_leaves(profile; k=25)— by first non-noise/non-wrapper frame (the user-code call site that actually allocated)top_alloc_frames(profile; k=25)— by every frame in every sample's stackBuilt-in noise patterns drop Julia runtime / GC /
Profile.Allocs/loader frames; built-in HBJ-wrapper patterns drop
benchmark_memory!and package-internal frames so leaf views show actual user code. Both
sets are extensible via
extra_noise/extra_wrapperskwargs.report_alloc_profileis a pretty-printer that calls all three.Also adds
Printfto[deps]/[compat](was implicitly loaded byother deps but not declared).
Test plan
Pkg.test()passes locally — 295 passing, including theanalyze: top_alloc_types / leaves / framestestset that builds asynthetic
AllocProfileResult, verifies noise filtering, scaling,and
extra_noise/extra_wrappersthreading.JuliaFormatterclean against the repochore/github-alignmentbranch (its only commit beyond main is the orphaned merge)