Repository navigation
Conversation
…les via a lazy bridge The main-thread receiver no longer imports the worklet registry and call bridges. main-renderer's thread-function entry points — the modules compiled worklet output and useMainThreadRef actually import — provide a bridge slot the receiver resolves once per install, so a bundle that compiles no worklet features retains none of the machinery (rig app main slice 70,384 -> 67,828 gzip). Worklet-addressed traffic arriving at a no-worklet bundle reports cleanly. lynx-bundle-size now emits frozen per-slice gzip budgets and ratios.json gates each slice against them. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_013br9KPN1riTSP683xEvUuU
This was referenced Aug 9, 2026
Huxpro
added a commit
to Huxpro/lynx-js-framework-benchmark
that referenced
this pull request
Aug 9, 2026
…k tip entries/octane now builds from Huxpro/octane#15 (lynx/receiver-diet 4a53620f, octane 0.1.31, stacks lynx-perf 1→7) instead of the original wire-fix PR branch. Full re-run supersedes every octane cell; latest.json verified in sync. vs octane-main: select@10k 9.7x, selectStorm@10k 8.3x, update10th@10k 5.9x, storms now 2-2.6x faster (the PR#1-era storm regression is gone), startup ~1.35x, wire select@10k 2.36MB -> 429B. Flag: BTS heap @10k rows measured 466MB vs main's 254MB — the one dimension moving the wrong way.
This was referenced Aug 9, 2026
14 of 17 tasks
This was referenced Aug 11, 2026
Owner
Author
|
Conclusion: close as failed by the live runtime gate. The worklet bridge reimplementation regressed selectStorm by 20.2 percent; a narrower genuinely-cold optional-worklet investigation continues in Huxpro/octane issue 44. |
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 #8. Stacked on #14 ([lynx-perf 6], base
lynx/protocol-slim), which stacks on #13 → #12 → #11 → #10 → #1.Summary
main-renderer.ts's thread-function entry points — the modules compiled worklet output anduseMainThreadRefactually import — provide a side-effect-free bridge slot (core/worklet-bridge.ts), and the receiver resolves it once per install. A production main-thread bundle that compiles no worklet features now sheds the entire registry/call-bridge machinery; worklet-addressed messages and hostrunWorkletdispatches arriving anyway report cleanly instead of resolving.benchmarks/lynx-bundle-sizenow emits frozenslice-budget-preview/slice-budget-ifrreference targets, andratios.jsongates preview-main, IFR-main, background, and whole-bundle gzip against them independently (1.03× headroom each).Why
main-thread.tsimported the registry statically — the rig table app uses zero worklets and paid for all of it. The registration mechanism (worklets.tson the packagesideEffectslist, module-scope definition maps) makes the module un-shakable once edged, so the boundary has to be a provided slot, not an import.worklet-bridge.ts): a module-scopeprovide()can never be conditional under bundlersideEffectssemantics — a side-effectful module is evaluated whenever any included module imports it, and a pure module containing the provide gets skipped by re-export tracing. The only reliable lazy boundary is a provide inside called functions that exist only in main-thread-only modules. That is why the wrappers live inmain-renderer.tsand not inworklets.ts(which the background slice shares — putting the provide there would have dragged the main-thread registry into background bundles of worklet apps).Changes
packages/lynx/src/core/worklet-bridge.ts(new): side-effect-free bridge slot —provideLynxMainThreadWorkletBridge(first provider wins) /installedLynxMainThreadWorkletBridge, bridgingcreateRegistry,installRegistry,installCallBridge,isolateWorkletValue,isBackgroundFunctionDescriptor.packages/lynx/src/main-renderer.ts: the seven thread-function re-exports become bridge-providing wrappers (registerThreadFunction,unregisterThreadFunction,bindThreadFunction,attachThreadFunction,invokeThreadFunction,runOnMainThread,runOnBackground), anduseMainThreadRefprovides before creating its descriptor — every entry point that can put a worklet feature in front of the receiver provides the bridge at module-evaluation/call time, which precedes the receiver's install in any statically bundled app.ensureLynxMainThreadWorkletBridgeis exported for harnesses that hand-register throughworklets.ts.packages/lynx/src/main-thread.ts: drops all value imports fromworklets.ts(type-only remain); resolves the bridge once per install; registry creation, registry/call-bridge installation, ref-owner publication, owner release, and close are all null-guarded; acall-maininto a bridge-less receiver answers with a cleancall-main-error("compiled no main-thread worklets"), a hostrunWorkletdispatch reports and returnsundefined; host hooks (runWorklet+ the__FlushElementTreere-entrancy wrapper) stay installed unconditionally. The container optionworkletsis passed only when resolved (host-driver already models it as optional with a clean host error).packages/lynx/src/first-screen.ts:runOnMainThread/runOnBackgroundre-export the wrappers;main-thread.ts's tail re-exports do the same. Layer identity contract updated inpublic-api.test.ts: the main-thread layer'srunOn*pair is the one wrapper, distinct from the background layer's core implementation.benchmarks/lynx-bundle-size/run.mjs: emits the two frozen slice-budget reference targets.benchmarks/baselines/ratios.json: four new guards with justifications.worklet-bridge-boundary.test.ts(see Validation);thread-calls/main-thread-eventsprovide the bridge explicitly (they hand-register throughworklets.ts, standing in for compiled output);runtime-compatibilitysource-graph inventory addsworklet-bridge.ts. Changeset:@octanejs/lynxpatch.Measured
Deterministic slice sizes (tasm decode + gzip -9, same instrument as the recorded baselines; baseline = #14 head
e627ca59):The two issue items resolved by measurement instead of code:
Octane …diagnostic strings, 10,153 raw bytes — but stripping all of them changes the slice by −234 bytes gzip (repetitive prose is nearly free under gzip, and gzip is the gate metric). The projected win was based on raw bytes. The related "self-audit" candidate —selfCheckLynxBackgroundInboundMessageon the receiver's own dispatch path — was already development-folded by [lynx-perf 5]'s validation diet; the prod slice contains zero validate/selfCheck occurrences.main-renderer.ts'srenderPlanNodeis a live renderer (components,if/switch, slots, try/suspense, context) producing first-screen nodes;plan-wire.ts's expansion is a static command stamper for the wire. The genuinely shared surface is a few dozen lines of prop/text canonicalization — an expected win well under 1 KB gzip, bought with real regression risk in first-screen semantics. Not a good trade under this PR's no-behavior-change constraint; left as a named non-change.FCP@10k (Lynx-for-Web,
createView→ first header text, fresh page per rep): interleaved A/B on the same host window — baseline medians 4,390/4,075/4,013 ms across three 2-rep rounds, after 4,128/4,109/4,945 ms. No resolvable delta; host noise (±900 ms between reps) dwarfs any parse effect of −2.5 KB. Reported as unchanged, not improved.Web harness sanity (1 rep, 1k + 10k): octane completes every op with zero DNFs on this head.
Acceptance vs issue #8:
usedExportsDCE had already dropped most of the projected mass, [lynx-perf 5/6] had already dev-folded the validation/handle machinery, and the two remaining projected levers measure at −234 B (strings) and <1 KB (unification). The realized, durable win is the worklet machinery no no-worklet app pays for again — enforced by gates and tests.Validation
pnpm typecheckpnpm format:filesacross every changed filepackages/lynx/tests— 28 files / 306 tests green (includes the new suite)pnpm test— full root run on this head: 1,558/1,577 files, 16,923 tests passed / 106 skipped; the 19 failing files diff empty against the perf(lynx): validation diet — dev-deep, prod-fast commit validation ([lynx-perf 5]) #13/perf(lynx): protocol slimming — derived ack handles, merged completion, empty-commit elision ([lynx-perf 6]) #14 baseline's pre-existing environmental set (Playwright-dependent browser suites, macOS-only rspeedy native demo, website SSR e2e) — zero new failuresnode benchmarks/bench.mjs --only lynx-bundle-size --ratios→ PASS (6 guards: 2 pre-existing relative + 4 new budgets)node benchmarks/bench.mjs --only lynx-table --ratios --quick→ PASS (14 guards; wire counters untouched)worklets.tsvalue import inmain-thread.ts→ the no-worklet esbuild probe fails and bothmain_gzipbudget gates breach (+2.3 KB); removing therunWorkletnull guard and thecall-mainclean error → both behavioral no-bridge tests failNew regression suite (
worklet-bridge-boundary.test.ts):registerThreadFunctionusage or auseMainThreadRefimport brings them back (markers chosen from code strictly behind the bridge, not fromworklets.tsmodule scope, which every bundle still evaluates for the built-in ref-owner registrations).call-mainwith the clean remote error, and reports a host-dispatched worklet instead of crashing.Risk / follow-ups
import()evaluated afterinstallLynxMainThreadwould resolve no registry for that install (worklet props then fail with the existing "requires a main-thread worklet registry" host error). No supported Lynx main-thread build produces that shape — the MT slice is a single statically-evaluated script — and the failure is loud, not silent.installLynxMainThreadwith a scriptedexecuteMainThreadWorkletand no bridge no longer isolates the scripted result before dispatch (the host owns the shape there); real installs isolate exactly as before.Provenance
agent-authored)🤖 Generated with Claude Code
https://claude.ai/code/session_013br9KPN1riTSP683xEvUuU
Generated by Claude Code