Skip to content

perf(lynx): frame-aligned commit pacing for the dual-thread transport - #10

Closed
Huxpro wants to merge 1 commit into
claude/octane-lynx-benchmark-payload-a3zaeufrom
lynx/commit-pacing
Closed

Huxpro wants to merge 1 commit into
claude/octane-lynx-benchmark-payload-a3zaeufrom
lynx/commit-pacing

Conversation

@Huxpro

@Huxpro Huxpro commented Aug 9, 2026 •

Copy link
Copy Markdown
Owner

Stacked on #1 (lynx/bench-wire-instrumentation → lynx/bench-website-viz → lynx/wire-payload-change-size); implements [lynx-perf 2] frame-aligned commit pacing (issue #3), the follow-up PR #1 flags for the storm trade-off.

Summary

  • The background transport now dispatches at most one non-empty commit per main-thread frame (commitPacing: 'frame', the default; 'immediate' restores unpaced dispatch). The first commit after idle crosses immediately — pacing never taxes one-shot latency.
  • Protocol: commits gain an optional pace: true flag; main answers each applied paced commit with a new frame-pulse MT→BG message at its next frame boundary, which reopens the background dispatch gate. Inbound validation is unconditional; outbound self-checks stay LYNX_DEVELOPMENT-gated.
  • Main-thread frame source resolution: options.frameScheduler → lynx.requestAnimationFrame → target.requestAnimationFrame → none. With no frame source the pulse is answered synchronously, so pacing degrades to today's immediate dispatch — Node harnesses and the deterministic rig behave byte-identically (only the 12-byte "pace":true flag moves the select commit 225→237B, far under the 2048B budget).
  • A commit held while the previous one's frame is open keeps folding interim renders through the existing awaiting-acknowledgement contract, so held time turns into batching: the deterministic paced storm collapses from 5,000 commands to 300 at 1k rows.
  • Empty-command batches always cross unpaced. Universal-core commits one (empty) batch per scheduled flush after a fold; pacing those would spend a frame each to learn nothing. They now skip the gate entirely, and only pace: true commits consume frames (3 framed commits for a 50-tick storm).
  • Liveness: a held dispatch force-opens after 64ms (PACE_SAFETY_MS, ~4 frames) if the frame source stalls (hidden Lynx-for-Web page throttling rAF); a pre-acknowledgement rejection reopens the gate since it consumed no frame.
  • Profiler gains a dispatch-side pacedCommits counter so the rig can gate "frame-consuming commits ≤ frames elapsed" — the issue-[lynx-perf 2] Frame-aligned commit throttling — recover the storm wall-clock deliberately #3 acceptance in deterministic form.

Measured

Deterministic rig (node benchmarks/lynx-table/run.mjs 3, drift-checked across iterations): all existing counters unchanged except select bytes 225→237 (the pace flag). New paced scenario (injected frame source, one frame per 2 macrotask turns, 1k rows):

storm (50 ticks × 100 changed rows) commits frame-consuming commands
unpaced 50 — 5,000
paced 50 (47 empty fold-tail, crossing unpaced) 3 300

Lynx-for-Web wall clock (this host, 4× Xeon, same instrument both runs, medians of n=3, ratios vs vue-vdom measured in the same run; baseline = stack tip e14d6001 measured back-to-back with this diff):

op baseline with pacing
updateStorm@1k 570 (2.73×) 383 (1.57×)
updateStorm@10k 4347 (1.36×) 3524 (1.07×)
updateStorm@30k 11497 (0.85×) 13687 (0.91×)
selectStorm@10k 1685 (1.08×) 1388 (0.87×)
selectStorm@30k 4370 (0.90×) 3386 (0.69×)
select@10k 831 (5.45×) 776 (4.84×)
update10th@10k 984 (4.62×) 1000 (4.58×)
create@10k 4506 (1.97×) 4516 (1.99×)

Validation

  • pnpm format:check
  • pnpm typecheck
  • pnpm test — 16,883 passed / 18 failed in 19 files, run twice with an identical failure list; all pre-existing, none in the lynx or universal projects. 17 files are Playwright/Chromium browser & e2e suites that cannot launch in this container (pinned chromium_headless_shell-1228 binary absent); rspeedy-plugin native-demo needs the macOS Lynx Explorer; website ssr-smoke /benchmarks card-count assert (28 ≠ 26) reproduces identically on the base stack tip e14d6001 with this diff absent — reported on feat(lynx): change-size-proportional commit wire cost, with a gated cross-framework benchmark (integration of 3 upstream PRs) #1.
  • targeted tests: lynx project 25 files / 280 tests green on the rebased stack (includes new commit-pacing.test.ts, 6 tests); universal-transport + universal-native suites green (48 tests)
  • node benchmarks/bench.mjs --quick --ratios lynx-table PASS (9 guards incl. 3 new paced guards)
  • red-checks: gate hold disabled → pacing tests 1 & 4 fail; reject-reopen removed → test 5 fails; empty batches paced again → update_storm_paced_frame_commits_1k guard breaches at 2.00×

Risk / follow-ups

  • Fold-tail empty commits: universal-core re-renders once per scheduled flush after a fold and commits the empty diff (47 empty ~150B envelopes per 50-tick storm). They no longer cost frames, but eliding them entirely requires universal-core + main accepted-version accounting (main validates call-main/dispose identities against its own accepted version, so the background cannot silently skip wire versions). This is the empty-commit-elision item in [lynx-perf 6] Protocol slimming: lazy ack handles, merged completion, empty-commit elision #7.
  • The safety valve is wall-clock (64ms); on a stalled frame source a held commit adds up to that much latency once, never in steady state.
  • One-shot latency and effects-after-accept ordering are pinned by tests (first-commit-immediate, pulse-answered-idle tap, rejection retry).

Provenance

  • An agent produced this diff (agent-authored)

🤖 Generated with Claude Code

https://claude.ai/code/session_013br9KPN1riTSP683xEvUuU


Generated by Claude Code

At most one non-empty commit dispatches per main-thread frame: the first
commit after idle crosses immediately, and a commit prepared before the
previous one's frame ended is held until main answers that apply with the
new frame-pulse message at its next frame boundary. Held time folds interim
renders through the existing awaiting-acknowledgement contract, so a storm
of ticks batches instead of queueing a commit per tick. Empty-command
batches always cross unpaced (they mutate nothing on main and must not
spend frames), a 64ms safety valve force-opens the gate when the frame
source stalls, a pre-acknowledgement rejection reopens it, and
commitPacing: 'immediate' restores unpaced dispatch. Hosts without a frame
source answer pulses synchronously, which degrades pacing to today's
immediate behavior and keeps the deterministic wire gates stable.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013br9KPN1riTSP683xEvUuU
@Huxpro

Huxpro commented Aug 11, 2026

Copy link
Copy Markdown
Owner Author

Conclusion: close as not mergeable. The unconditional frame-pulse pacing mechanism is rejected; live-main pacing research continues in Huxpro/octane issue 45 with a backpressure and zero-command settlement gate.

@Huxpro Huxpro closed this Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant