Repository navigation
test(bench): size the first-screen prop memo before building it, and refute the cheap version - #264
Merged
Merged
Conversation
…refute the cheap version #247's bucket-4 attribution puts publish at 0.79 of the FCP gap at 10,000 rows, and the function profile inside it puts cloneProps at 27.7 ms and planLynxHostPropPatch at 11.7 ms. The steady-state mount-template-run path already memoizes both on the props object's identity through prepareStaticHostProps; the first-screen walk at host-driver.ts:5040 calls them unconditionally per node. Pointing one at the other is the cheapest-looking cut in the attribution, so this counts what it would actually buy before anyone writes it. It buys nothing, and the census says so exactly rather than approximately. At 10,000 rows the first-screen walk visits 60,028 host nodes and 40,028 of them are non-text -- against 40,028 distinct props objects. The renderer allocates a fresh bag per node, so an identity-keyed memo has a hit rate of 0.0000 and adding one would cost a WeakMap lookup per node to miss every time. The same census says what would work. Half of all first-screen hosts (30,015, 50.0% at both scales) are already memo-eligible on every other test -- frozen, one key, that key class or className carrying a string, with zero misses for any other reason -- and those 30,015 nodes resolve to 7 distinct (type, class) pairs. Seven, at 1,000 rows and at 10,000 alike, because the class strings come from the template rather than from the data. A value-keyed memo hits 0.9998. Whether that is worth building is a separate question this does not answer, and the sizing argues no: the class-only half are the cheapest clones in the bucket, so the addressable share of those 39.4 ms is well under half of it, against a +/-0.04 resolution that is about +/-42 ms of wall at this scale. The cut has no host-call count oracle either, because it changes no host calls. The census is a tally, not an ablation: it changes no host call and no painted output, and the paint oracle recorded beside each scale is the evidence of that. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019RsC3U39kUuLKajZANeTVy
Three gate items of one class: - the checked-in census record was hand-assembled and prettier-red; rewritten through writeEvidenceJson, values untouched. - the census build CLI silently dropped a typo'd --scales entry and accepted a negative one; parses before filtering and refuses both. - bts-profile and papi-floor still wrote records with a bare tab stringify — the same latent defect #268 fixed in heap-retention; both now write through the evidence writer. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01YHfFsy9CLaRovTFH8pTGyY
Huxpro
marked this pull request as ready for review
August 31, 2026 19:11
This was referenced Aug 31, 2026
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
#247's bucket-4 attribution (#254, and the report on #247) names
publishas the observed owner — 0.79 of the FCP gap at 10,000 rows, two-window spread 0.015 — and the function profile inside it putsclonePropsat 27.7 ms andplanLynxHostPropPatchat 11.7 ms.There is an obvious-looking cut there. The steady-state
mount-template-runpath already memoizes both the clone and the patch on the props object's identity (host-driver.ts:7323); the first-screen walk athost-driver.ts:5040calls them unconditionally, per node, on the critical path to first paint. Two paths, same work, one of them already memoized.This PR counts what pointing one at the other would buy, before anyone writes it. The answer is nothing.
Why
prepareStaticHostPropskeys its memo on the props object's identity. At 10,000 rows the first-screen walk visits 60,028 host nodes, of which 40,028 are non-text — against 40,028 distinct props objects. The renderer allocates a fresh bag per node, so:#text(excluded by design)(type, class)valuesAdding the identity-keyed memo would cost a
WeakMaplookup per node in order to miss every single time.The same census says what would work, and it is a striking number: half of all first-screen hosts are already eligible on every other test — frozen, one key, that key
class/classNamecarrying a string, with zero misses for any other reason — and those 30,015 nodes resolve to 7 distinct(type, class)pairs. Seven, at both scales, because the class strings come from the template rather than from the data. The clone and the patch are both pure functions of that pair.Whether to build the value-keyed version — the sizing argues no
Recorded here so the next reader does not have to re-derive it:
cloneProps's 27.7 ms +planLynxHostPropPatch's 11.7 ms is well under half of 39.4 ms.fcp-attribution.mdis explicit that counts are the reliable currency here and milliseconds are for sizing.So the cut that can actually move bucket 4 past the line is the structural one — take record building off the critical path entirely (83.2 ms, the whole
host record buildingbucket, built solely to feedcaptureLynxFirstTree) rather than shave the clone. That is #68.Labelled: the sizing above is a bound, not a measurement of the candidate — no value-keyed memo was built or measured. The one effect it does not bound is allocation pressure: 30,015 object allocations and freezes replaced by 7 cache entries could have GC knock-on beyond the direct self time. That is a hypothesis, and it is the only argument left for building it.
Changes
stages/fs-props-census-source.mjs— build-time source patch that tallies, at the first-screen walk site, whatprepareStaticHostPropswould decide and why, plus distinct props objects and distinct(type, class)pairs. Same shape asstages/instrument-source.mjs: unambiguous anchors or it throws, and it restores the file after one build.stages/fs-props-census-build.mjs— builds the census bundles (--universal, because the profiled cell is the universaloctaneone; the MTS-program cell paints its first screen from the compiled program and never enters this walk at all).stages/results/c247-fsprops-census.json— the recorded tally at both scales, with the paint oracle beside each.The second commit adds no measurement and changes no recorded value; it is gate repair, described under Validation.
Validation
new-lynxcheckout and restores it to a clean treeclassCountmatching, checksums recordedpnpm format:files:checkon both authored filespnpm sync— no generated changespnpm typecheckpnpm testThis is a census, not an ablation: it changes no host call and no painted output, which is what the paint oracle beside each scale establishes.
benchmarks/is in novitest.config.jsproject, so no test project reaches these files; the recorded tally is the result.The format check above was scoped too narrowly, and the second commit is the repair.
pnpm format:files:checkran on the two authored.mjsfiles, which is what that line claims and all it claims — it did not cover the third changed file,stages/results/c247-fsprops-census.json, which was hand-assembled and did not match whatwriteEvidenceJsonemits. That record would therefore have failedCheck formattingthe moment this PR left draft, which is exactly the failure that turnednew-lynxred earlier today and that #268 fixed for three other records.600907136rewrites it through the writer (72 lines reflowed, values untouched — the tally in the table above is unchanged), and takes two neighbours with it:bts-profile.mjsandpapi-floor.mjsstill wrote their records with a bare tab-indentedJSON.stringifyand now go through the writer too. It also givesfs-props-census-build.mjsthe same--scalesvalidation as #263's build script, so a typo'd or negative scale is refused rather than silently dropped into a partial arm.Risk / follow-ups
host-driver.tsand throws on a miss rather than silently producing an uninstrumented bundle, but a reflow of the first-screen walk will need them re-fitted.typecheck,lint,apply labels); every heavy job reportsskipped, which is whatci.ymldoes for a draft, not a failure. Nothing has yet run the heavy suite against this diff.bts-profile.mjsandpapi-floor.mjsbecause they were adjacent, but nothing yet enforces that a stage probe writes throughwriteEvidenceJson.evidence.test.mjschecks the checked-in records, so it catches the drift after it lands rather than stopping a new probe from introducing it.Provenance
agent-authored)Generated by Claude Code