Repository navigation
perf: attribute what survives a clear, instead of naming the gap - #252
Merged
Merged
Conversation
…tention-attribution
A record that does not name its code cannot be compared to another one, and this probe's largest managed-heap row is one `WeakRef` per painted element — so its readings move whenever the compiler changes how many elements a row paints. That is not hypothetical. The record checked in with this probe was taken before #250 folded a compile-time-known text child onto its `text` host. Taken again after, on the same probe at the same scale, the retained total is half what it was and the `WeakRef` row falls from 70,000 nodes to 60,000 — exactly one fewer per row. A reader holding both files could not have told which was which, because neither said. The generated report now names the commit and whether the tree was dirty, in its own second paragraph rather than only in the JSON, because the report is the artifact that gets quoted. Stamping is never fatal: a checkout without git records a null stamp rather than losing the measurement. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019RsC3U39kUuLKajZANeTVy
…lements Same probe, same scale, same core, on the current base rather than the one this branch was cut from. Every bucket reproduces the unstamped run that preceded it byte for byte, which is what a structural count should do. What moved, and it is not noise: - `object:WeakRef` falls 70,000 -> 60,000 nodes. That is exactly one fewer per row at 10,000 rows, and one `WeakRef` per painted element is this probe's one verified mechanism. The instrument tracked a known element-count change to the integer. - The live `array:` row falls 120,013 -> 110,013 nodes, the same exact 10,000. - Retained over `fresh` halves, 2.38 -> 1.17 MiB. The earlier record is kept rather than replaced. It measures different code and neither supersedes the other; the recipe now names the commit each was taken at so the pair can be read as the comparison it is. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019RsC3U39kUuLKajZANeTVy
Huxpro
marked this pull request as ready for review
August 31, 2026 07:39
5 of 6 tasks
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
#241's retention oracle is a scalar: one post-collection
Runtime.getHeapUsagereading. A scalar can say a 3.3 MB gap exists (heapMtsAfterClear10.21 vs 7.37 MB) and can never say who owns it — #230's rule that a named remainder nominates nobody applies to a heap number exactly as it applies tooff_boundary. That is why E2 closed on clear cost and explicitly did not close on retention.This adds the instrument that turns the gap into named buckets, and the recipe that lets someone else re-run it.
benchmarks/lynx-table/stages/heap-retention-analyze.mjs— the pure half. Folds a V8 heap snapshot intobucket -> {bytes, count}, diffs two aggregates, and ranks growth. Separate from the probe because it decides a claim, and a claim generator is worth testing without spending a measurement window.benchmarks/lynx-table/stages/heap-retention-analyze.test.mjs— 10 tests, red-verified.benchmarks/lynx-table/stages/heap-retention.mjs— the driver. Four captures on a fresh page per repetition:fresh,afterCreate,afterClear, and a second create-and-clear asafterClear2.docs/measurement/heap-retention-attribution.md— the recipe, besideheap-after-clear.md.The fourth capture is what makes the other three readable. One cycle cannot distinguish an array still holding rows from an array that grew a backing store for them and kept it. Cycle two draws that line, and it is the difference between a leak and a high-water mark.
Two records, because the base moved under this branch
This branch was cut at
432c64859. Merging the live base brought in #250, which folds a compile-time-known text child onto itstexthost — so a row now paints six elements where it painted seven. This probe's largest managed-heap row is oneWeakRefper painted element, so that is not a detail: it moves the headline number.Both records are checked in. Same probe, same scale, same core, different code:
c230-retention-10000c252-postcausea-10000432c64859a4d22e295(on4081baf73)freshobject:WeakRef, cycle 1array:, cycle 1array:, cycle 2native:system / JSArrayBufferData, cycle 1array:nodes (afterCreate−fresh)The instrument tracked a known cause to the integer, which is the strongest check it can pass.
object:WeakReffalls by exactly 10,000 nodes at exactly 10,000 rows — one per row, matching one folded element per row — and the livearray:node count falls by exactly the same 10,000. Cause A's element diet is visible in the retained heap at full precision, and #252'sWeakRefmechanism claim comes out of the base change strengthened rather than stale.The
WeakRefmechanism is verified, not hypothesised. Every__Create*in@lynx-js/web-core's main-thread element layer hands anew WeakRef(dom)to the Wasm element table:60,000 wrappers at 10,000 rows is exactly 6 per row on the current base (70,000 was exactly 7 before the fold). The retained table shows no
x-view,x-text,ShadowRootorNamedNodeMaprow, so the referents died and only the wrappers survived. Cycle two adds none, so the table reuses its slots: bounded, not compounding.The two
c252-postcausearuns — one before the commit stamp existed, one after — reproduce every bucket byte for byte, which is what a structural count should do and a wall-clock number could not.The record now names the code it measured
The comparison above was only possible because I generated one of the two records myself. Neither file said which commit it came from: the JSON carried Node, Chromium, load and bundle path, and the markdown — the artifact that actually gets quoted into issue comments — carried none of it.
So the generated report now names the commit and whether the tree was dirty, in its own paragraph near the top.
dirty: truedisqualifies a record for comparison and the report says so in bold. Stamping is never fatal: a checkout without git records a null stamp rather than losing the measurement.c230-retention-10000predates the stamp; its base is recorded in the recipe doc instead.Validation
node --test benchmarks/lynx-table/stages/heap-retention-analyze.test.mjs— 10 pass, 0 fail on the merged base, red-verified with two deliberate probes (hardcoding theself_sizeoffset broke the offsets test; dropping shrinking buckets broke the negative-rows test; both restored).pnpm syncclean;pnpm format:fileson both changed files.pnpm format:check/pnpm typecheck/pnpm test— not run repo-wide. This branch touches onlybenchmarks/lynx-table/stages/anddocs/, no published package source.The 1,000-row record was produced before the second-cycle capture existed and its shape no longer matches what the writer emits — the same staleness that makes
stages/results/issue57-clear-teardown.jsonfail today, so it was dropped rather than committed. Itsarray:figure is still quoted below because it is a bucket total, not a record shape.Risk / follow-ups
array:is still unowned, and is now the dominant named managed-heap grower — 90.4% of the second cycle's retention against 42.2% of the first. It halved with Cause A (1,047,864 → 519,032 B) but still grows by roughly its own size every cycle, so it is unbounded exactly as before.The follow-up Order now has a prediction to confirm rather than a graph to fish in. The bucket's net growth matches, at every measured point, a single 8-byte-per-slot array whose capacity is the smallest power of two ≥ the live painted-element count:
The residual is the same constant at two scales three doublings apart, which is what a fixed offset from the rest of the bucket looks like and what a curve fit does not. Since
object:WeakRefis exactly one per painted element and lives in web-core's Wasm element table, the natural candidate is that same table's backing store — which would make the two largest managed-heap rows one owner, not two.Stated as a hypothesis under The create residual: attribute it, tax-test it, then extend compiled programs to steady-state mounts (E-train) #230: it is arithmetic agreement across three (scale, code) points, not a retainer path. Confirming it needs the edge-graph walk this probe deliberately does not do, and naming the owner without that walk would be the exact move this instrument exists to prevent.
This changes what the oracle means, not what the runtime does. No package source is touched.
Branch naming. The harness assigned
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.Self size, not retained size: a bucket names an owner-of-bytes, never a root cause.
Provenance
agent-authored)Generated by Claude Code