Repository navigation
perf(lynx): classify host updates without building the prop patch (issue-66 A4) - #92
Merged
Merged
Conversation
`updates.classify` answers one question — can this host be updated in place, or must it be recreated. Both Lynx drivers answered it by running the full semantic prop diff and keeping a single boolean, then discarding the patch. On the background client driver nothing else ever read it, and the main thread rebuilt the same patch from the same props bag a moment later in `prepareLynxHostBatch`. That is the run-and-discard double diff named in issue #66 §3 A4. `classifyLynxHostPropUpdate` answers it directly. Losing a CSS scope is the only condition that makes a host un-updatable in place, and that verdict needs neither the attribute diff, the dataset bag, the class composition, nor the patch object. What is skipped is construction and comparison, never a rejection and never a property read: every validation still runs in the same order, so a rejected update is still rejected on the same thread with the same error instead of relocating to a main-thread host fault, and every walk is kept so both paths touch the same own-properties of the bag in the same order. Differential: 7,168 type x fragment pairs plus 21,504 merged-bag pairs must agree with `planLynxHostPropPatch().requiresRecreate` on the verdict and on the exact thrown message, with corpus guards so the agreement cannot go vacuous. Red-green verified across six deliberate breaks. Measured same-window on a quiet host, AB/BA. Seam, over the 4,000 real triples captured from lynx-table@10k, 40 passes, n=9: 178 ns/call -> 40 ns/call, ratio 0.224x, ranges separated. End-to-end runTable(10000), fresh process per sample, n=7: 7,367.2 ms -> 7,263.3 ms, ratio 0.986x with overlapping ranges — within noise, and the arithmetic agrees (51,065 calls times ~138 ns is ~7 ms of ~7,300 ms). No whole-path performance is claimed. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019RsC3U39kUuLKajZANeTVy
This was referenced Aug 19, 2026
Huxpro
marked this pull request as ready for review
August 19, 2026 18:30
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
updates.classifyis the renderer's question "can this host be updated in place,or must it be recreated?". Both Lynx drivers answered it by running the full
semantic prop diff and keeping one boolean:
The patch was then discarded. On the background client driver nothing else ever
looked at it, and the main thread rebuilt the same patch from the same props bag
a moment later in
prepareLynxHostBatch. This is the run-and-discard double diffcalled out in issue #66 §3 A4.
classifyLynxHostPropUpdateanswers the same question directly. Losing a CSSscope is the only condition that makes a host un-updatable in place, and that
verdict needs neither the attribute diff, the dataset bag, the class
composition, nor the patch object.
Why
The classifier runs once per updated host per commit on both threads. On the
lynx-table10k operation sequence that is 51,065 calls, each of which built andfroze a patch object, an attribute-patch array, and a dataset bag that nothing
read.
This also gives the delta work a prop-bag-independent classification contract to
build on: the later A4/A5 slices change how an update is represented on the wire,
and
updates.classifymust not be reaching into a full props bag to answer aquestion about CSS scope.
Changes
packages/lynx/src/core/host-props.ts: addclassifyLynxHostPropUpdateplusthe shared
assertNoDirectMainThreadTextPropshelper that both it andplanLynxHostPropPatchnow use for the raw-text rejection.packages/lynx/src/core/client-driver.ts,host-driver.ts: bothupdates.classifyimplementations call it.packages/lynx/tests/host-prop-classification.test.ts: the differential.What is skipped is construction and comparison, never a rejection and never a
property read. Every validation
planLynxHostPropPatchperforms still runs inthe same order, so a rejected update is still rejected on the same thread with
the same error rather than relocating to a main-thread host fault; and every
walk is kept so both paths touch the same own-properties of the bag in the same
order, with only the allocation dropped. That second half matters because the
work that looked skippable is throw-free but not read-free:
normalizeLynxClasscannot reject a value,
attributeValuecoerces only<image>sources, and thedataset normalizer rejects exactly one name (
data-) — but all three read fromthe bag on their way there. Keeping the reads costs nothing measurable (see
below) and removes an entire class of divergence rather than arguing it is
unreachable.
Validation
Differential: for every
type × fragmentpair over 7 host types and 32 propfragments — 7,168 pairs, plus 21,504 merged-bag pairs — the classifier and
planLynxHostPropPatch().requiresRecreatemust agree on the verdict and onthe exact thrown message. The corpus is itself guarded (
>20recreate verdicts,>200rejections) so the agreement cannot go vacuous.Red-green verified — each deliberate break was applied, the suite run, and the
break reverted:
pnpm typecheckpnpm sync(no generated changes)pnpm format:fileson every changed pathpnpm vitest run --project lynx— 29 files / 366 tests passedpnpm test— 20,961 passed, 5 failedpnpm format:check(not run repo-wide;format:filescovers every path thisdiff touches)
All 5 failures are pre-existing in this container, established rather than
assumed: the same five files were re-run on the base commit
c3baf805aandproduced the identical five failures, same test names.
drei/tests/browser/upstream-e2e.browser.test.tsraw.githack.com→raw.githubusercontent.com; the Three.js loader rejects withCould not load …. No commit in this stack touchespackages/drei.rspeedy-plugin-octane/tests/native-demo.test.tsrspeedy-plugin-octane/tests/browser/web-host.test.tsoctane/tests/browser/suspense-hydration/…dropzone/tests/probes/hydration.test.tsThe container ships Chromium
1194while playwright 1.61 wants1228; thesymlink workaround issue #66 §2 prescribes is what lets these projects run at
all, and is the likely reason the browser cases are unstable here.
Measurement
Same-window A/B, quiet host (1-minute load 0.27 on 4 logical CPUs), AB/BA
alternation. Absolute milliseconds are host-bound and are not comparable across
sessions or hosts.
Seam — both classifiers over the 4,000 real
(type, previous, next)triplescaptured from the
lynx-table10k sequence (the distribution is 99.9%#text{value}→{value}, the restview{class}→{class}), 40 passes, n=9:planLynxHostPropPatch().requiresRecreateclassifyLynxHostPropUpdatesame-window ratio 0.224×; the ranges do not overlap. An earlier variant that
dropped the property reads as well as the allocations measured 0.221×/39 ns — the
same to within noise, which is why read parity was kept.
End-to-end — full
runTable(10000)through the real dual-thread path, freshprocess per sample, n=7: base 7,367.2 ms (6,967.5–7,822.4), candidate 7,263.3 ms
(6,754.5–7,395.9), ratio 0.986×. A second window measured 0.979×.
That end-to-end number is not a performance claim. The ranges overlap
heavily, and the arithmetic says they should: 51,065 calls × ~138 ns saved is
about 7 ms against a ~7,300 ms sequence, or 0.1%. The honest reading is that
this removes provably redundant work and per-update allocation from the commit
path with no measurable whole-path effect in this harness.
The per-stage intervals this harness reports are not offered as supporting
evidence, in either direction.
updates.classifyruns during commit planning,before
dispatch, so it is inside none of them; anddispatchMsis not a wirecost — the in-process
ContextProxydelivers synchronously, so the intervalaround
context.dispatchEvent(transport.ts:336-338) contains the wholemain-thread receive pipeline plus the harness's own per-message
JSON.stringifybyte counter (
workload.ts:94). Reading it as serialization cost would be amistake;
benchmarks/lynx-table/README.mdalready says wall clock belongs tothe browser harness and this runner owns deterministic counts.
Not measured: the browser stage harness (
stages/run.mjs) and FCP. Neithershould move — this touches no first-screen path.
Risk / follow-ups
sharing one function body. If a future change teaches
planLynxHostPropPatcha second recreate trigger,
host-prop-classification.test.tsfails untilclassifyLynxHostPropUpdatelearns it too — that is the intended tripwire, andthe corpus guards keep it honest.
planLynxHostPropPatchitself is unchanged and still owns every path thatactually consumes a patch.
cost is the walks that can reject, and shrinking those further would mean
moving a rejection off the background thread — a behavioural change, not an
optimisation, and not one this slice should make.
Provenance
agent-authored)Generated by Claude Code