perf(memtrack): stop capturing stacks on free - #558
Conversation
|
96e3091 to
6a35299
Compare
Merging this PR will improve performance by 19.2%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ⚡ | WallTime | memtrack track tar |
9.4 s | 7.9 s | +19.2% |
Tip
Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.
Comparing cod-3703-eval-performance-overhead-of-memory-flamegraphs (c01f5d2) with main (fabf8e4)
Footnotes
-
4 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
This comment has been minimized.
This comment has been minimized.
Memory flamegraphs only attribute allocations: the platform unwinds free stacks and never reads the result. Capturing them doubled the per-event probe cost, the stack ring traffic, and the archive's stack bytes. The Free event no longer carries a stack_hash. Artifacts from older memtrack versions that still have the field decode unchanged. Refs COD-3703
Free events no longer carry a stack, and the stack_hash field on Free was never part of a release (v5.3.1 ships Free as a unit variant). Revert Free to a unit variant instead of keeping a deprecated always-zero field, and update callers, tests, and snapshots.
381195e to
c01f5d2
Compare
Why
Memory flamegraphs only attribute allocations. The platform's
memtrack-parserunwinds stacks attached toFreeevents and caches the callchain, but only allocation samples are folded, so free stacks are never read.With stack capture on by default, every
free()still paid the full capture: an 8 KiB user-stack copy, the FNV hash,bpf_get_stackid, and (since exact-hash dedup is ~0% effective) a full record into the stack ring. That is roughly half of all captures.What
freeuprobe no longer callscapture_stack;submit_free_eventdrops the hash.MemtrackEventKind::Freeis a unit variant. The serialized form is unchanged (stack_hashwas already skipped when zero), and artifacts written by older memtrack versions with astack_hashon frees still decode (covered bylegacy_free_with_stack_hash_decodes).Freewithout thehas_stackflag.Expected effect
About half the stack captures, stack ring writes, encode CPU, and archive stack bytes on allocation-heavy benchmarks; less unwinding work in callgraph generation. To be measured on the platform memory shards (COD-3703).