Repository navigation
feat(lynx): stop re-sending an unchanged worklet every render - #124
Merged
Merged
Conversation
U4b made a worklet-bearing keyed list mount in three commands. The frame after it did not follow: an identical re-render of a three-row list emitted three `update` commands, each carrying its row's whole prop bag, where the same list without the prop emitted nothing. At 1,000 rows that is 1,000 updates per render — the mount cost U4b deleted, moved to the update path. The cause is a value the core cannot read. `bindThreadFunction` returns a fresh tagged function every render, and the core's definition of unchanged is identity, then a bounded structural walk that stops above a worklet's captures. It says "changed" and it is not wrong to: it has no way to know what the fields of a renderer's descriptor mean. So it now asks. The `updates` capability gains an optional `same(name, previous, next)`, consulted only for a prop the core has already judged changed. That ordering is the whole safety argument: a renderer can widen equality and never narrow it, so implementing this can only remove update commands, and a driver that supplies none keeps every existing decision byte-for-byte. The obligation it takes on is that "equal" must mean the renderer's own applier would have made no change from the update it suppressed. Lynx answers for `main-thread:` props through `sameLynxMainThreadPropValue` — the same decode-then-compare `planLynxHostPropPatch` already performs, so a suppressed update is one the applier would have turned into an empty patch. A malformed descriptor stays the applier's to report: a decode that throws declines to call the values equal and ships the update that raises it, in the applier's own words at its own point in the commit. The hook is consulted after the core's own answer and inline at each diff site, so an unchanged prop costs exactly what it did before and a renderer that claims nothing costs one null check per changed prop. `--only lynx-table --ratios` holds with every operation count unchanged, which is that claim measured: those fixtures carry no worklet, so the driver declines every name. Co-Authored-By: Claude <[email protected]> Claude-Session: https://claude.ai/code/session_019RsC3U39kUuLKajZANeTVy
This was referenced Aug 21, 2026
block-core's write() used the raw structural compare, so a malformed descriptor already in a slot made every later setKeyedSlotValue throw at the compare — the slot could never be repaired through the write API. sameLynxUniversalHostPropValue is the single comparator that owns the contract (decode failure declines equality and ships the update that lets the applier report it), so write() now uses it. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01YHfFsy9CLaRovTFH8pTGyY
Huxpro
changed the base branch from
feat/lynx-universal-worklet-runs
to
new-lynx
August 21, 2026 21:03
Huxpro
marked this pull request as ready for review
August 21, 2026 21:03
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
#103 U4c, stacked on #122. U4b made a worklet-bearing keyed list mount in
three commands; the frame after it did not follow. An identical re-render of a
three-row list emitted three
updatecommands, each carrying its row's wholeprop bag, where the same list without the
main-thread:prop emitted nothing:main-thread:bindtap× 3update×3At 1,000 rows that is 1,000 updates per render — the mount cost U4b deleted,
moved to the update path. Measured end to end through
createLynxRootover thereal transport, before and after, and committed as a test.
Why the core was not wrong
bindThreadFunctionreturns a fresh tagged function every render, and thecore's definition of unchanged is identity, then a bounded structural walk that
stops above a worklet's captures. It says "changed" — correctly, given what it
can see. It has no way to know what the fields of a renderer's descriptor mean,
and teaching it would put
main-thread:inside the universal core, which isexactly what the universal/renderer split exists to prevent.
So it asks instead.
Changes
octaneUniversalHostUpdateCapabilitygains an optionalsame(name, previous, next). The core consults it only for a prop it hasalready judged changed. That ordering is the whole safety argument: a
renderer can widen equality and never narrow it, so implementing this can only
remove update commands — never add, reorder, or force one — and a driver that
supplies none keeps every existing decision byte-for-byte. The obligation it
takes on is stated on the interface: "equal" must mean the renderer's own
applier would have made no change from the update it suppressed.
octaneuniversal-core.tsthreads the driver's answer through every propdiff site — five prop-bag (
shallowPropsEqual) and three program-slot — as asingle resolved-once member, null when the driver claims nothing. The
consultation is inline at each site rather than behind a helper, so an
unchanged prop costs exactly what it did before the hook existed.
@octanejs/lynx: both drivers answer through a newsameLynxUniversalHostPropValue, which claimsmain-thread:names anddefers to
sameLynxMainThreadPropValue— the same decode-then-compareplanLynxHostPropPatchalready performs. That is what makes suppressing soundrather than merely cheaper: an update this removes is one the applier would
have turned into an empty patch. A malformed descriptor stays the applier's to
report — a decode that throws declines to call the values equal and ships the
update that raises it, in the applier's own words at its own point in the
commit.
docs/universal-renderer-architecture.md: the driver interface listing gainsthe new optional member.
Validation
pnpm format:check(repo-wide, clean)pnpm typecheck(repo-wide, clean)pnpm test— 5 failed / 21,061 passed / 8 skipped; none of them this diff's--project lynx454 passed;--project octane+octane-prod12,446 passed in a dedicated run, with zero test failures
node benchmarks/bench.mjs --only lynx-table --ratios— PASS, and everyoperation count unchanged (
create=1,update10th=100/1000,select=2,swap=2,updateStorm=50c/5000). Those fixtures carry no worklet, so thedriver declines every name — the "additive" claim measured rather than
argued.
Every failing file in the full run was attributed individually:
dropzoneprobes/hydration,octanebrowser suspense-hydration(focus/selection after a keyed reorder),
dreibrowser upstream-e2e (WebGL),and
rspeedy-pluginnative-demoper Execution plan (#58): complete L2, then drive L4→L6 — full context handoff #66 §2.3;octanereact-hosted/web3-island (2 passed),
ariapackage-boundary (6 passed), andadapter-verceladapt (8 passed, 506ms against a 5s deadline). All three arefixed-deadline hooks or imports that bundle or compile, and the run they
failed in took 3,488s wall.
markdownconformance/public-types, which fellinto this bucket on feat(lynx): mount a worklet keyed list through one template run #122's run, passed here — the set moves run to run, which
is the signature.
Red-first, per changed source file:
universal-core.tshost-props.ts+ both driversTests:
packages/lynx/tests/worklet-template-runs.test.ts— newre-sends a row handler only when the handler changes: an unchanged list emitsnothing, and moving the handler's captures still emits the update on every
row, because captures are what the handler will act on. The existing
destroy-with-the-row case gets simpler and stronger at the same time — the
survivors now keep the executions the run gave them, so it asserts that
directly instead of chasing whichever execution the frame happened to carry.
packages/octane/tests/universal-host-sdk.test.ts— newlets a renderer widen prop equality but never narrow it, driving a classinstance (the core's own documented identity-only boundary) through both a
prop bag and a program slot in one frame. It pins the ordering directly: the
renderer is never asked about the unchanged
label, which is why a driveranswering
falsefor a name it does not own cannot turn an equal prop into anupdate. Its sibling
keeps the core's own answer when a driver claims no prop namesholds the un-hooked path at today's two updates.Risk / follow-ups
samewrongly suppresses a real update. That is thecost of the escape hatch and the reason the obligation is written on the
interface rather than implied; Lynx discharges it by reusing its applier's own
predicate rather than writing a second one.
sameLynxMainThreadPropValueapplied to program-marked slots. Both paths nowroute through that one predicate, so they cannot disagree about what "changed"
means — which was the point of extracting it.
worklet descriptor every render before discovering it is unchanged. That cost
is per changed-looking prop rather than per command and is not what the 1,000
updates measured; shrinking it is a separate question about where encoding
happens.
Provenance
agent-authored)Generated by Claude Code