Repository navigation
perf: name the owner of the array: retention bucket by walking the edge graph - #258
Merged
Merged
Conversation
The fold names which constructors hold the surviving bytes and stops, because self size over every node is exact where a retained size double-counts. That was enough to close `object:WeakRef` with a mechanism and not enough to close `array:`, which after #250 is the dominant named grower in the managed heap. `array` is V8's own type for an unnamed backing store, so the bucket name is the shape of the thing and never its owner. This adds the walk the fold declines: `immediateRetainers` collects every edge that lands on a node in one pass over the edge table, and `buildRootPaths` reaches every node from the GC root once, keeping the edge that first found it. Both are recorded because they answer different questions — the retainer list is exact, while a shortest chain from a root is a nomination to go and read. Off unless `--attribute <bucket>` is passed. It costs an edge pass and a breadth-first walk on a snapshot the probe otherwise drops as soon as it is folded, which is worth paying once a bucket has earned it by size and by growing per cycle, and worth paying never otherwise. Eight tests, each red-verified: keeping only a node's first retainer, printing an indexed edge as a named one, spelling an unreachable node as an empty path, and hardcoding the `self_size` column each break their own test and restore. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019RsC3U39kUuLKajZANeTVy
…s not say The recipe's closing section said the probe cannot name what points at a bucket. It can now, so the section is replaced rather than appended to: a doc that describes a missing capability is worse than one that describes none. Two limits stay, and they are the ones a reader is likely to overstep. A retainer path names an owner in the heap, not a line of source. And it does not rank owners: self size says how big a node is and the chain says who reaches it, but neither says how much would be freed if that owner let go, which is a dominator-tree question this probe does not answer. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019RsC3U39kUuLKajZANeTVy
The bucket is web-core's WebAssembly externref table. The walk lands on it in one hop — the node is held by exactly one edge, `object:Table` via `[2]` — and the chain from the GC root runs through `.__wbindgen_externrefs` on the Wasm instance's exports. That closes it against the mechanism already verified beside it. Every `__Create*` in web-core hands `new WeakRef(dom)` to that same table, which is why `object:WeakRef` is exactly one node per painted element. The two largest managed-heap rows are therefore one owner, not two: the wrappers are the table's entries and the array is the table's backing store. The size confirms it without appeal to the path. The node is 524,296 bytes: 65,536 slots at 8 bytes, plus an 8-byte header. 65,536 is the smallest power of two above the 60,000 elements a 10,000-row page paints after #250. The same arithmetic lands on every earlier reading — 8,192 slots at 1,000 rows, 131,072 before the fold — with a residual of exactly -712 bytes at two scales three doublings apart, which is a fixed offset from the rest of the bucket rather than a fitted curve. And it explains the per-cycle growth the first record could only report. The table is sized by elements ever created, not by elements alive: a second create-and-clear takes the cumulative count to 120,000, which crosses into 131,072 slots and adds 524,288 bytes. The record observed 524,432. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019RsC3U39kUuLKajZANeTVy
--attribute paid the edge scan and whole-graph BFS on all four captures of every repetition while only the median afterClear table is recorded; the other three phases now skip the walk, which is the file's own 'worth paying never otherwise' note applied to itself. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01YHfFsy9CLaRovTFH8pTGyY
Huxpro
changed the base branch from
perf/lynx-heap-retention-attribution
to
new-lynx
August 31, 2026 15:17
1 task done
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
The follow-up Order #252 filed. Its probe names which constructors hold the surviving bytes and stops there deliberately, so
array:was left as an owner-shaped hole — and after #250 it is the dominant named grower in the managed heap, 90.4% of the second cycle's retention.arrayis V8's own type for an unnamed backing store, so the bucket name describes the shape of the thing and never its owner.Stacked on #252. Review that one first; this branch is the three commits on top.
The answer
array:'s dominant node is web-core's WebAssembly externref table. The walk lands on it in one hop — the node is held by exactly one edge — and the chain from the GC root names it:That closes it against the mechanism already verified beside it. #252 established that every
__Create*in@lynx-js/web-corehandsnew WeakRef(dom)to the Wasm element table, which is whyobject:WeakRefis exactly one node per painted element. So the two largest managed-heap rows are one owner, not two: the wrappers are the table's entries, and the array is that same table's backing store.The size confirms it without appealing to the path
The node is 524,296 bytes = 65,536 slots × 8 B + an 8-byte header, and 65,536 is the smallest power of two above the 60,000 elements a 10,000-row page paints after #250. The same arithmetic lands on every reading this probe has ever produced:
The residual is the same constant at two scales three doublings apart — a fixed offset from the rest of the bucket, not a fitted curve — and the direct node measurement is the header exactly.
And it explains the per-cycle growth the fold could only report
#252 recorded
array:growing by roughly its own size every create-and-clear cycle and could not say why. The table is sized by elements ever created, not by elements alive. A second cycle takes the cumulative count to 120,000, which crosses into 131,072 slots and adds 524,288 bytes. The record observed 524,432.So the growth is real and unbounded, and its owner is not Octane's code. It is a dependency's table that never releases capacity. What Octane controls is how many elements it asks that table to hold — which is exactly the quantity #250 reduced, and exactly why the retained total halved.
Changes
benchmarks/lynx-table/stages/heap-retainer-paths.mjs— the walk.immediateRetainerscollects every edge landing on a node in one pass over the edge table;buildRootPathsreaches every node from the GC root once, keeping the edge that first found it. Both are recorded because they answer different questions: the retainer list is exact, a shortest chain from a root is a nomination.benchmarks/lynx-table/stages/heap-retainer-paths.test.mjs— 8 tests.heap-retention.mjs—--attribute <bucket>, off by default, plus the report section.docs/measurement/heap-retention-attribution.md— the recipe, and the two limits that remain.stages/results/c252-array-owner-10000.{json,md}— the record.A full reverse index was written and then removed. It costs eight bytes per edge across millions of edges to answer a question asked about ten nodes, and the probe already declines to hold the raw snapshot for that reason. One sequential edge scan is exact and allocates nothing.
Validation
targeted tests:
node --test benchmarks/lynx-table/stages/heap-retainer-paths.test.mjs— 8 pass, 0 fail;heap-retention-analyze.test.mjs— 10 pass, 0 fail.every guard red-verified — each mutation broke its own test and restored:
immediateRetainerskeeps only a node's first retaineredgeLabelprints an indexed edge as a named one[2])rootPathForanswers[]for an unreached nodenodesInBuckethardcodes theself_sizecolumnthe driver ran end-to-end at 10,000 rows, 3 repetitions, quiet host (load 0.02/CPU), clean tree; the result reproduced identically across three independent runs.
pnpm syncclean;pnpm format:fileson every changed file.pnpm format:check/pnpm typecheck/pnpm test— not run repo-wide. This branch touches onlybenchmarks/lynx-table/stages/anddocs/, no published package source.The stamp #252 adds caught my own error within the hour. An exploratory run was taken while I had the recipe doc open, and its record came back
dirty: trueand said so in bold. By the rule that doc states — a dirty record is disqualified for comparison — it was discarded and re-run clean rather than shipped.Risk / follow-ups
object:Tableis where the bytes live; going from there to the call that grew it is still reading. Under The create residual: attribute it, tax-test it, then extend compiled programs to steady-state mounts (E-train) #230 the path and the sizes are verified; "this is why the bytes survive" is not claimed beyond the one-hop retainer, which is exact.@lynx-js/web-corechange and belongs in that conversation, not this one. What is actionable on our side is already named: fewer painted elements is fewer table slots, which is Octane paints 7 elements per benchmark row where Vue paints 4 — audit the row's element diet; it is also the ART-ceiling denominator #242's element diet.claude/octane-issue-66-phase-a-7wz97zfor this session, butcreate-a-prrequires afeat/|fix/|docs/|test/|perf/topic branch solabel-pr.ymlcan read the type. A topic branch was used; flagging the conflict rather than resolving it unilaterally.Provenance
agent-authored)Generated by Claude Code