Repository navigation
Conversation
…wire commands The compiler already hoists every host template as a universalPlan shared by both bundles; the wire never used it. The background now re-encodes each provable plan instance — its creates, listeners, and root insert — as one instantiate(planId, parent, before, ids, values, events) command, and the main thread expands it back into identical per-node commands before the untouched validation and Element PAPI apply paths run. Identity is content-derived (canonical serialization, double FNV-1a), so structurally identical plan constants hash alike across bundles with zero compiler changes. The main thread registers eligible plans at its universalPlan facade and announces the IDs in the ready reply plus incremental plan-registry messages; the background folds only announced IDs, so registry skew degrades to per-node commands and protocol stays version 1. An announced-but-unresolvable plan rejects the commit. create@10k drops 160,000 -> 10,000 wire commands (1.00x the new one-instantiate-per-row model floor) and the create commit serializes at 31% of its former size; every other deterministic counter is byte-identical. Wall-clock create is unchanged within noise on the 4-core web host — crossing volume was not the bottleneck there — with a runtime probe confirming folding is active in the real Rspeedy bundles. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_013br9KPN1riTSP683xEvUuU
This was referenced Aug 9, 2026
Owner
Author
|
Conclusion: close as superseded. The structural compact-template and incremental-run work in octanejs/octane PRs 693 and 700 replaces this older plan-wiring approach. |
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.
Closes #5. Stacked on #11 ([lynx-perf 3], base
lynx/auto-memo), which stacks on #10 → #1.Summary
instantiate(planId, parent, before, ids, values, events)command each, replacing that instance's per-node create/event/insert commands. Mounting a table row costs 1 wire command instead of ~16; create@10k drops from 160,000 commands to exactly 10,000 and the create commit serializes at 31% of its former size (−69%).universalPlanfacade and announces the IDs in its ready reply (plus incrementalplan-registrymessages for lazily loaded chunks). The background folds only announced IDs, so registry skew, HMR drift, lazy chunks, or a hash collision all degrade to the per-node commands exactly as before — protocol version stays 1, and a main thread that announces nothing sees byte-identical traffic.Why
universalPlanshared by both bundles, and the wire never used it.instantiate(planId, instanceId, slotValues[]); the landed shape carries explicitids(pre-order) andevents(listener tokens) instead of an opaqueinstanceIdbecause both threads must agree on per-host IDs for the acknowledgement handle deltas and the accepted-listener table — expansion regenerates the same IDs the background staged, so the ack path needed no changes at all.Changes
packages/octane/src/universal-core.ts: staged batches carryplanInstancesprovenance — each fully-new, visible, plan-rooted host subtree with its plan, slot values, pre-order host IDs, and staged listeners — only for async transports that declare the newplanInstantiationcapability. Non-opted transports see byte-identical batches. Subtrees containing lifecycles, local callbacks, portals, retained or invisible nodes are never attributed.packages/lynx/src/core/plan-wire.ts(new): canonical plan serialization + content-derived wire IDs (collision → poisoned-ID eviction), the realm-local plan registry, static wire-shape eligibility (rejectspropsSlot, key/ref/children bindings,main-thread:*bindings, if/switch/component nodes, event∩value slot aliases), the background fold (two-pass footprint proof: an instance folds only when its commands are exactly its creates + events + one root insert, with no foreign command touching its IDs), and the main-thread expansion that regenerates identical per-node commands.packages/lynx/src/core/transport.ts: tracks announced plan IDs frommain-ready/plan-registry; folds the wire message only — handle-delta validation and worklet lifetimes keep reading the per-node prepared batch, which mirrors what main regenerates on expansion.packages/lynx/src/main-thread.ts: announces registered plans in every ready reply and re-announces late registrations; expands instantiate commands before the untouched prepare/apply/ack paths; an unresolvable plan ID rejects the commit like any other malformed batch.packages/lynx/src/main-renderer.ts: registers every eligible compiled plan constant at theuniversalPlanfacade — the whole main-side registry with no compiler involvement.packages/lynx/src/core/protocol.ts:instantiatecommand validation (exact keys, positive-integer IDs, wire-leaf values, typed event entries),planson the ready reply, and theplan-registrymessage.packages/lynx/tests/plan-wire.test.ts(new, 11): cross-facade identity (background and main-renderer facades normalizeprops: {}/absent differently — canonicalization treats them identically), eligibility rejections, staged→folded→expanded round-trip equality, fallback and disqualification paths.packages/octane/tests/universal-plan-instances.test.ts(new, 8 × two projects): provenance staging, retained instances not re-attributed, lifecycle-containing wrappers excluded, no opt-in → noplanInstanceskey.packages/lynx/tests/milestone-7-integration.test.ts: three new dual-realm scenes over the real compiled layers — fold happy path (announced plans → instantiates on the wire, correct DOM, live taps, update retains identity with zero instantiates, insertion folds exactly one, late registration announces), per-node fallback when nothing is announced, and registry corruption rejecting the commit.packages/lynx/tests/protocol.test.ts: instantiate/plans/plan-registry validation cases.benchmarks/lynx-table:main-layer.ts— the same app compiled with the main-thread renderer in a second vite build, mirroring the device's dual bundles;run.mjsbridges its registered plans into the workload realm and pins a real create model floor (one instantiate per row).benchmarks/baselines/ratios.json:create_commands_{1k,10k}guards at the one-command-per-row floor.octanepatch (plan-instance provenance),@octanejs/lynxpatch (plan-aware wire).Measured
Deterministic (in-process dual-thread rig, real tap tokens, drift-checked across iterations; every non-create counter byte-identical before/after):
node benchmarks/bench.mjs --only lynx-table --ratios→ PASS, 25 guards checked. Red-check: the pre-change head measures 16.0× the new create floor, so reverting the fold breaches both new guards; the three new integration scenes and the round-trip test also fail against a reverted implementation, and the octane provenance tests fail with the staging gate flipped.Acceptance vs issue #5:
Lynx for Web wall clock (same 4-core host, all four cells re-run back-to-back, identical instrument, medians of n=3), before → after:
+b:cexperiment showed create is PAPI-bound, and the 16× reduction in per-command clone+validate volume was not the wall-clock bottleneck on this host. What instantiate does not remove: background staging still materializes per-node commands before folding, and main-thread expansion regenerates them before the PAPI apply loop. Reaching the 2400–3000 band needs the react-tier work the issue explicitly scoped out (code-staged MT create — materializing the plan directly to PAPI without intermediate command objects), now the honest candidate follow-up.Validation
pnpm format:check(scopedformat:files:checkon all changed files)pnpm typecheckpnpm test— full root run on this head: 16910 passed / 106 skipped. 21 failed files = the 19 pre-existing environmental files (identical set to the PR perf(octane): transported universal roots adopt retained subtrees — render breadth proportional to change size ([lynx-perf 3]) #11 baseline: Playwright-browser suites without a Chromium download, macOS-only rspeedy native-demo, website ssr-smoke/benchmarkscard count) + 2 lynx contract assertions this diff legitimately moved — the runtime source-graph inventory gainingplan-wire.tsand the first-screen ready reply now announcing plans — both updated in this PR and green.packages/lynx/tests(26 files / 295 tests, two-realm rig with validation on, incl.plan-wire11 and the three new milestone-7 scenes),universal-plan-instances+universal-transport(both octane and octane-prod projects)node benchmarks/bench.mjs --only lynx-table --ratios→ PASS (25 guards)Risk / follow-ups
framesPumped) is wall-clock sensitive through the transport's 64ms pace safety valve: one contended run showed a one-frame drift (5→4) while unrelated heavy tasks shared the host; quiet-machine runs are stable across 4 iterations on both heads. Pre-existing sensitivity, unrelated to this diff.Provenance
agent-authored)🤖 Generated with Claude Code
https://claude.ai/code/session_013br9KPN1riTSP683xEvUuU
Generated by Claude Code