Skip to content

feat: alloc profile analyzer (top_alloc_types/leaves/frames + report) - #12

Merged
jack-champagne merged 1 commit into
mainfrom
feat/alloc-analyzer-rescue
May 20, 2026
Merged

feat: alloc profile analyzer (top_alloc_types/leaves/frames + report)#12
jack-champagne merged 1 commit into
mainfrom
feat/alloc-analyzer-rescue

Conversation

@jack-champagne

Copy link
Copy Markdown
Member

Summary

Re-lands the alloc profile analyzer on main. HBJ#8 was merged at
2026-05-20T06:54:09Z into chore/github-alignment — but HBJ#10
(chore/github-alignmentmain) had been squash-merged 4 minutes
earlier, so #8 landed on an already-orphaned branch. src/analyze.jl
never reached main; merge commit afca64c is stranded on the stale
chore/github-alignment branch.

This PR replays the exact same content onto a fresh branch off
current main. Diff is byte-for-byte equivalent to HBJ#8 (verified
via git diff origin/main origin/chore/github-alignment over the four
touched files).

What's in the PR (same as HBJ#8)

Three query functions return Vector{AllocFrameSummary} sorted by
allocated bytes, with optional 1 / sample_rate extrapolation:

  • 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 that actually allocated)
  • top_alloc_frames(profile; k=25) — by every frame in every sample's stack

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.

report_alloc_profile is a pretty-printer that calls all three.

Also adds Printf to [deps] / [compat] (was implicitly loaded by
other deps but not declared).

Test plan

  • Pkg.test() passes locally — 295 passing, including the
    analyze: top_alloc_types / leaves / frames testset that builds a
    synthetic AllocProfileResult, verifies noise filtering, scaling,
    and extra_noise / extra_wrappers threading.
  • JuliaFormatter clean against the repo
  • CI green on Julia 1.10/1.11/1.12 + Formatter
  • Close the orphaned HBJ#8 merge by deleting chore/github-alignment
    branch (its only commit beyond main is the orphaned merge)

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).
@jack-champagne
jack-champagne merged commit c38418c into main May 20, 2026
4 checks passed
@jack-champagne
jack-champagne deleted the feat/alloc-analyzer-rescue branch May 20, 2026 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant