Skip to content

fix(bench): make Lynx startup measurable on Native - #886

Merged
trueadm merged 1 commit into
octanejs:mainfrom
Huxpro:feat/lynx-performance-entries
Aug 30, 2026
Merged

trueadm merged 1 commit into
octanejs:mainfrom
Huxpro:feat/lynx-performance-entries

Conversation

@Huxpro

@Huxpro Huxpro commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Reproduction

The Native acceptance run in Huxpro#199 loaded a clean Octane table bundle in LynxExplorer with enable_perf_metrics=true. Lynx emitted exactly one standard loadBundle pipeline entry, including openTime, lynxFcp, totalFcp, and pipelineEnd, but both Octane runtimes then failed during module evaluation:

ReferenceError: MessageChannel is not defined

The required lynx-native-startup-v1 producer receipt never appeared, so the benchmark correctly kept the cell as DNF rather than publishing the platform entry as a successful first screen.

The unconditional constructor is in the benchmark fixture, not the renderer scheduler: benchmarks/lynx-table/app/src/App.lynx.tsrx created its storm MessageChannel at module scope. Current packages/octane/src/runtime.ts already has its own setTimeout fallback.

Accident history

The benchmark methodology previously recorded that Octane's custom renderer did not expose the common pipeline boundary, and its checked-in adapter consequently suppresses Performance.getAllPerformanceEntries for the current Octane entry. The #199 device run corrected that premise: the engine already stamps the standard entry once per loadBundle, even when the application subsequently fails.

That makes a renderer-side timing hook the wrong fix. It would risk a duplicate entry and would still allow a failed application to look successful. Acceptance has to remain the conjunction of the engine entry and a versioned producer receipt proving transport acknowledgement, two Native frames, and semantic row state.

The conflict with the original D2 plan is recorded before this change in Huxpro#232: Huxpro#232 (comment)

Remove the failure class

  • use MessageChannel when the runtime provides it and the timer task queue otherwise;
  • publish lynx-native-startup-v1 only from the background root's thenable root.render() result, after its real transport acknowledgement and two Native animation frames;
  • include the exact semantic row snapshot expected by the benchmark consumer;
  • never publish a receipt from the synchronous main-thread first-screen entry;
  • gate both properties with a regression test that deletes MessageChannel before running the real 1k table workload, including both storms, and pins the receipt ordering/shape.

No timing marker is added to packages/lynx. The engine owns the loadBundle entry. The direct first-screen path, decline to background command path, and adoption continue to use their existing renderer behavior; this patch does not import or alter that program/adoption machinery. The receipt source has a single publication site on the live background root, and the existing first-screen suite continues to cover direct paint/adoption and the documented native-list decline path.

This branch is based directly on octanejs/octane@main; the transport codec commit from #885 is not an ancestor and no codec, validation-mode, program, or adoption implementation is included.

Validation

  • production Lynx/Web table app build passed;
  • built Native bundle: 492,871 bytes, SHA-256 5f7646aca90fab3a6be72ec756018676f59b13bcf1d7649bb6d782f167b1a015;
  • real table workload with globalThis.MessageChannel deleted: 1k and 10k passed, including 50 update-storm and 30 select-storm commits;
  • new Native fixture regression: 2/2;
  • focused Lynx first-screen/main-renderer/runtime-compatibility: 44/44;
  • pre-existing Lynx table stage files: 5/5;
  • full upstream CI Vitest configuration, same four shards and excludes: 1,789 files, 21,001 tests, 1 skipped;
  • pnpm typecheck;
  • pnpm format:check;
  • pnpm sync with no tracked drift;
  • pnpm changeset:check.

Exact-device acceptance: blocked

The branch's exact 492,871-byte bundle was fetched and opened on leased Sandbox device aic-i18n-bd-fullport.byteintl.net:55864, but acceptance failed rather than remained pending:

  • Performance.getAllPerformanceEntries returned zero entries for this bundle, an archived Octane control, and a known-good vue-vdom control. That Explorer install (versionName=1.0, versionCode=1, installed 2026-08-20) does not expose the engine pipeline entry that Add Cloudflare Workers adapter #199's earlier image did.
  • the Vue control emitted a valid versioned receipt, proving the consumer and receipt probe work.
  • this branch installed the semantic snapshot, returned a thenable from root.render(), and then waited indefinitely for its transport acknowledgement. D1+D2 without any readiness change reproduced the timeout.

Follow-up isolation on a second device corrected the initial attribution:

  • the immutable archived 0fc84da0 bundle (SHA-256 1f3b252d…) ACKed, but its preserved benchmark patch includes both a production string wire and a repeating correlated ready-request; it is not a fixture-only/current-main commit-range control;
  • a correctly dependency-isolated 0fc84da0 checkout with this exact D2 patch still returned a thenable and never ACKed;
  • restoring the original App stopped before the entry module because Native has no MessageChannel, confirming this PR's fallback is necessary; retaining the fallback while deleting the semantic snapshot block still hung, so the snapshot is not the cause;
  • D2 plus only a 16 ms readiness retry still timed out (493,138 bytes, SHA-256 1a337ac9…);
  • D1 + D2 + the identical readiness retry succeeded (499,299 bytes, SHA-256 3decf55d…) and emitted a valid lynx-native-startup-v1 receipt: module 1787924596401, ACK 1787924596456, frames 1787924596463 / 1787924596480, and the exact rows-0 semantic state.

The successful overlay proves two independent transport prerequisites: D1's encoded string wire and a separate listener-installation/readiness retry. Neither is the requested standard pipeline entry, and Performance.getAllPerformanceEntries remained empty. This PR contains neither prerequisite and does not import program/adoption work.

The conflicts, dependency-isolation correction, and orthogonal controls are recorded chronologically in Huxpro#232, including the fixture-control correction and the final readiness result. This PR remains Draft: it does not satisfy the required engine-entry + transport-ACK + two-frame acceptance, and no private ACK metric or synthetic pipeline marker is substituted.

Related: Huxpro#199, Huxpro#232.


Note

Low Risk
Changes are confined to the Lynx table benchmark fixture and its tests; no production renderer or auth/data paths are modified.

Overview
Fixes Lynx Native benchmark acceptance by removing the module-load MessageChannel crash and emitting the lynx-native-startup-v1 producer receipt the harness expects.

Storm scheduling in App.lynx.tsrx now creates MessageChannel only when it exists; nextMacrotask falls back to setTimeout(0) so update/select storms still run one commit per tick on Native.

Startup measurement moves into index.ts: after the background root.render() promise resolves, the app waits two lynx.requestAnimationFrame callbacks, reads __LYNX_BENCH_SNAPSHOT__ (new refs + snapshot hook on App), and sets __LYNX_BENCH_STARTUP__ / logs __NATIVE_BENCH_STARTUP__ with transport ack timing and semantic row fields. Render failures set __LYNX_BENCH_ERROR__.

native-fixture.test.mjs regresses the no-MessageChannel 1k table run (including storms) and pins receipt ordering/shape against the entry and snapshot source.

Reviewed by Cursor Bugbot for commit 7378d00. Bugbot is set up for automated code reviews on this repo. Configure here.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

@Huxpro

Huxpro commented Aug 30, 2026

Copy link
Copy Markdown
Contributor Author

Readiness-stack device update (D2 code remains unchanged):

I built and loaded the exact disposable stack upstream main (including #885) + readiness PR #909@9994674bba + this PR@7378d00477 with 1000 pre-rendered rows.

What this Sandbox image proves:

  • the stacked production bundle loads after fix(lynx): keep readiness requests alive #909's Lynx-correct bare timer binding;
  • D2 exposes the expected semantic snapshot: rowCount=1000, ids 1/2/3, row998Id=999, first label pretty red table, and no selection;
  • no D2 application error is reported.

What it cannot prove:

  • this LynxExplorer reports SDK 0.0.1 and has neither bare setTimeout nor globalThis.setTimeout;
  • therefore fix(lynx): keep readiness requests alive #909's 16 ms late-listener pulse cannot run on this image, and __LYNX_BENCH_STARTUP__ remains null;
  • I am not claiming the transport ACK or two post-ACK frames on this device.

The environment conflict and the decision not to broaden either PR were recorded first in Huxpro/octane#232. #909 remains the independent readiness transport fix based on the compatible-device semantics already verified in Huxpro#233. This PR's three-file patch and scope are unchanged.

@Huxpro

Huxpro commented Aug 30, 2026

Copy link
Copy Markdown
Contributor Author

#909 is now Ready and its complete upstream CI gate is green: run 33311512894 passed every Node 24 test shard, React parity shard/aggregate, heavy package/Astro and Chromium lane, website/examples, package validation, compatibility, lint, typecheck, and provenance job.

This does not change the device conclusion in the previous comment: the available Explorer SDK lacks Lynx's documented timer global, so this PR stays Draft and ACK/two-frame acceptance is not claimed. The D2 branch/commit and three-file patch remain unchanged.

@Huxpro

Huxpro commented Aug 30, 2026

Copy link
Copy Markdown
Contributor Author

State correction: this PR is currently Ready, not Draft. The timeline shows maintainer trueadm marked it Ready at 2026-08-30T11:26:56Z; my previous comment repeated stale state. I am leaving the maintainer-selected state untouched.

The technical caveat remains exactly as written: the currently available Explorer image cannot claim ACK/two-frame acceptance, and this PR's SHA/files are unchanged.

@trueadm
trueadm merged commit dce99bc into octanejs:main Aug 30, 2026
96 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix PR: bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants