Skip to content

SPIKE: heap profile as an introspection source, attributed to operators - #40357

Draft
antiguru wants to merge 5 commits into
moritz/alloc-systemfrom
moritz/heap-introspection-spike
Draft

antiguru wants to merge 5 commits into
moritz/alloc-systemfrom
moritz/heap-introspection-spike

Conversation

@antiguru

Copy link
Copy Markdown
Member

Spike, not for merge. Exposes the allocation tracker's sampled live heap as two compute introspection sources, mz_heap_live_per_operator and mz_heap_stacks, attributed to the timely operator that made each sampled allocation. The sources join with mz_dataflow_operators, so a SUBSCRIBE keeps a per-operator heap breakdown up to date. misc/spike/heap-flame.html renders one as a live flame graph over the WebSocket SQL API.

Attribution needs to know the scheduled operator at allocation time. Timely's logger cannot provide it, because its events are buffered and arrive after the allocation. The spike therefore patches timely with TimelyDataflow/timely-dataflow#831, a thread-local holding the scheduled operator's identifier. The tracker reads it only for sampled allocations. TraceManager::maintenance and allow_compaction claim the arrangement's operator, so merge work driven from compute maintenance is charged to the arrangement.

On a local 4-worker replica with lgalloc off and a 64 KiB sample interval, the tracker accounted for 2280 of 2300 MiB anonymous RSS. Operators received 92% of it, 4% was unattributed (persist blob reads on tokio threads), and the rest was the logging dataflow, mostly the in-process symbolizer. Per arrangement, sampled heap matched mz_arrangement_sizes capacity within about 1%. With lgalloc on, the sources miss lgalloc's file mappings. In a 60 s CPU profile the scheduling hook and the snapshot code did not appear, and the tracker's sampling path took about 4.6% of samples at the 64 KiB interval.

Open points before a design: release images strip DWARF, so in-process symbolization yields function names only, and stacks should be symbolized off the replica by build ID. The tag also needs a runtime component if a process hosts more than one timely runtime.

🤖 Generated with Claude Code

@antiguru
antiguru added this pull request to stack #39869 October 29, 2026 17:08
@antiguru
antiguru force-pushed the moritz/heap-introspection-spike branch from cc2d385 to b7c4b0b Compare October 29, 2026 19:36
@antiguru
antiguru force-pushed the moritz/heap-introspection-spike branch from b7c4b0b to 755c20e Compare October 29, 2026 20:02

This branch has not been deployed

No deployments
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