Repository navigation
perf(lynx): plan a host create without diffing it against nothing - #272
Conversation
Every host prop patch a first screen plans is a create — 40,002 of 40,002 on the 10,000-row tree — and the planner derived the previous side of a diff for every one of them: `Object.keys` on the same empty bag 40,002 times, and for the 10,000 that reach the body past the shared-patch fast path, an id, class, inline style, dataset, CSS scope and main-thread ref derived from it too. All of it lands on the same constants every time. Name those constants and let a create enter the diff body with them already known. This is deliberately not a second planner: the comparison body, the refusals and the patch construction stay one implementation entered two ways, so the create and the update cannot answer differently. The update path keeps every derivation exactly where it was, because several can throw and hoisting them would reorder which refusal a malformed bag reports first; a create's cannot throw on an empty bag, which is what makes hoisting its side sound. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019RsC3U39kUuLKajZANeTVy
|
| red | shape | why it is not this diff's |
|---|---|---|
suspense-hydration › restores focused input and its selected text after a keyed DOM reorder |
failed test | browser focus/selection; red on c124594c7 with this whole stack absent (recorded on #269) |
drei › should match previous one |
failed test | headless screenshot comparison, 30 s waitForFunction timeout; same |
native-demo › escalates cleanup for a detached descendant after its leader exits |
failed test | process-tree signal escalation on a 100 ms budget, on a test named for macOS; same |
monaco-editor-browser › mounts a real editor with workers and accepts typed input |
failed test — locator.click 30 s timeout |
re-run alone on this head: still red; re-run alone on the base commit 03e68116d with this diff absent: red identically. Not load-induced and not this diff's — a headless click into a worker-backed Monaco editor in this container |
packages/aria/tests/hydration.test.ts |
beforeAll timeout, its test skipped |
the fixture build exceeds the default 10 s hookTimeout under load (verified passing alone on the base, 19.17 s wall, on #271) |
packages/octane/tests/react-hosted/web3-island.test.ts (octane, octane-prod) |
beforeAll timeout, its tests skipped |
the RainbowKit fixture exceeds the same 10 s budget in this container; red on c124594c7 with this stack absent |
The three beforeAll timeouts are why 7 files are red but only 4 tests failed:
their tests are skipped rather than run.
One change against #271's run, reported rather than smoothed over:
syntax-highlighter › fails closed for missing, extra, renamed, collided, stale, and removed-lane evidence was red there and is green here, while
monaco-editor-browser went the other way. Both are container-resource tests at
the edge of a fixed deadline, and the monaco one was checked against the base
commit rather than assumed.
Validation otherwise: pnpm typecheck clean repo-wide, --project lynx
49 files / 800 tests all passing, pnpm sync no generated changes,
pnpm format:files on every changed path.
Generated by Claude Code
Summary
The third cut of #247's publish work. Per the owner directive
(#247 issuecomment-5485061147): drive the compiled/direct path through
publishuntil the interpreted remainder is gone, using #254's phase segmentation as a
local build tool rather than a merge gate.
After #270 and #271, a fresh profile of
publishon their head namesplanLynxHostPropPatchat 120.6 ms over 7 screens, 17.2 ms per screen — thelargest contained frame left inside
publishthat is neither the walk itself northe capture that follows it. This PR stops it from diffing against nothing.
Every host patch a first screen plans is a create
Not "almost every". A census on the 10,000-row tree, counting calls and how many
arrive with an empty
previous:40,002 of 40,002. There is no update in a first screen — that is what a first
screen is — and yet the planner derived the previous side of a diff for every
one of them:
Object.keyson the same empty bag 40,002 times, each allocating anempty array, plus a
localPlainPropBagon it; and for the 10,000 that reach thebody past the shared-patch fast path, an id, class, inline style, dataset, CSS
scope and main-thread ref derived from that bag as well. All of it lands on the
same constants every time.
One body, two entry points
planLynxHostCreatePatchis deliberately not a second planner. This modulealready carries a warning against exactly that shape —
classifyLynxHostUpdate'scomment says its verdict "is exactly
planLynxHostPropPatch(...).requiresRecreate"so the two cannot drift — and a hand-written create planner would be the drift
that comment is about.
So the seven previous-side derivations are named (
PreviousPropSide), thediff body is unchanged and shared, and a create enters it with that side already
known as a frozen constant. There is nothing to keep in step: the comparisons, the
refusals, and the patch construction are one implementation, entered two ways.
The update path is byte-identical, deliberately. Each derivation stays exactly
where it was, guarded by
side === null, because several of them can throw andhoisting them would reorder which refusal a malformed bag reports first. The
create side can be hoisted precisely because none of the seven can throw on an
empty bag.
Changes
@octanejs/lynx:PreviousPropSideandNO_PREVIOUS_PROPSinhost-props.ts;planLynxHostPropPatchand the newplanLynxHostCreatePatchbecome two entrypoints onto one
planHostPropPatchbody; the ten create call sites inhost-driver.ts— first screen, template run, program plan, compact ACK,main-thread prop install, node materialization — take the create entry point.
The two genuine update sites keep
planLynxHostPropPatch.Correctness
The gate the directive keeps in full force is byte-identity between the old and
new publish path. Here that is a differential over the two entry points: for
19 scenes, each landing on a different branch of the shared body,
planLynxHostCreatePatch(type, next)must equalplanLynxHostPropPatch(type, empty, next)— for both spellings of "no previousprops" the driver used to pass, a prototype-less bag and a plain
{}. Eightrefusal scenes assert the two produce the same message, not merely that both
throw.
Two assertions exist because deep equality would not see them:
and a single-class host are meant to share one frozen patch across the whole
first screen;
cannot see because a break there moves both arms together.
Each was falsified before being trusted, per
octane-core-extend:lynxtests''nullnullEMPTY_DATASET''rather thannull''The last two are the reason those two extra assertions are in the diff: without
them, the first stays green across all 800
lynxtests and the second staysgreen across all but the differential.
Measurement
The web lane cannot resolve this cut, and per the directive it does not have
to — "a cut that shows nothing on V8 but is structurally sound still lands; the
target engine has no JIT to hide interpretation behind."
An interleaved 4-round A/B (10,000 rows, 60,002 described hosts, 9 reps/round,
arms alternating within each round):
publishpublishMedian-of-medians 314.5 → 315.1; best-min 254.0 → 254.2; two rounds each way,
arms fully overlapping. That is a non-result and it is reported as one.
What is exact, and is the reason the cut lands, is what stops happening per
first screen at 10,000 rows:
Object.keyscalls on an empty bag, and the 40,002 empty arrays theyallocate;
localPlainPropBagcalls on that same bag;decodeMainThreadRef,classProp,normalizeLynxClass,normalizeLynxInlineStyle,normalizeLynxDatasetFromNamesanddecodeLynxCSSScopeMetadataon it, plus ahasOwnper attribute prop.Roughly 160,000 calls and 40,002 allocations, removed rather than relocated. That
distinction is what separates this cut from the one #271 declined: there the
deleted scan's per-node comparisons moved into the loop that absorbed it, so only
loop overhead was actually removed. Here nothing moves — the work has no
destination, because its answer was already a constant.
Per #264 this is structural and not a cache: that census settled the memo
question (identity-keyed hit rate 0.0000 over 40,028 nodes; value-keyed declined)
and is not revisited here.
Spec-silent choices, noted rather than asked about
previousPropSide(previous)call would be tidier and would reorder refusalsfor a malformed previous bag —
decodeMainThreadRefwould throw before thereserved-namespaced-prop check. A stored bag was validated when it was
created, so this is unreachable today; it is still not worth spending.
a literal
{}rather than the driver's shared empty bag move too: both areempty, both are plain, and
planLynxHostCreatePatchanswers each identically —which the differential asserts for both spellings rather than assuming.
NO_PREVIOUS_PROPS.datasetisEMPTY_DATASET, the same shared objectnormalizeLynxDatasetFromNamesreturns for a bag with nodata-props, sosameDataset's identity short-circuit still fires for a propless create.sideisPreviousPropSide | nullrather than a boolean, so the constantslive next to the interface that names them and a reader can see what a create's
previous side is without reconstructing it from the guards.
Validation
pnpm typecheck— clean, repo-wide--project lynx— 49 files, 800 tests, all passpnpm test— running against this head; result posted below when it landspnpm format:fileson every changed pathpnpm sync— no generated changesNo cost assertion is added to a correctness test: exact allocation counts are an
optimization claim and belong in the benchmark ratio system, per
octane-core-extend. The counts above come from a local census instrument thatis not part of this diff.
Risk / follow-ups
planLynxHostCreatePatchis a new export fromcore/host-props.ts, which isinternal to the package. Nothing in
src/index.tsre-exports it.those merge.
publish, and why it is not here. The per-hoststate.generations.set(id, 1)— 60,002 map writes of one repeated value —already has
implicitInitialGenerationsfor exactly this on the compact path,but turning it on for the direct first screen would disable a later
incrementalCompactmount on the same container. That is a behaviour trade, nota free cut, and the lane cannot price it (ablation 321.9 against a 315.7 base).
It belongs to the device round, which is where the directive puts the
performance verdict.
claude/octane-issue-66-phase-a-7wz97z;this repo's
create-a-prrequires a type-prefixed topic branch so the label botcan read the type from it. The topic branch is used, and the deviation is
flagged here rather than resolved unilaterally.
Does this change the sequence?
No. This is B under the #247 directive, taken after A (#269) as instructed,
and it is the third cut inside
publishafter #270 and #271. It changes no ABI,no wire, and no phase boundary:
render→publish→capture→announcestill run in the one synchronous task before paint, which is why the cut had to
remove work rather than move it to
capture. It changes no refusal orderingeither — the update path's derivations stay exactly where they were, and a
create's cannot throw. #68's capture deferral is unaffected and still follows.
Provenance
agent-authored)Generated by Claude Code