Skip to content

[lynx-perf 2] Frame-aligned commit throttling — recover the storm wall-clock deliberately #3

Closed as not planned

Description

@Huxpro

Depends on: #1 landed ([lynx-perf 1]). The coalescing contract ("renders scheduled while a commit awaits ack fold into one commit carrying the latest state") is already explicit and tested in #1 — this issue is the wall-clock recovery it deliberately left out of scope (C1 in #1's risk notes).

The measured problem

Before #1, octane WON update storms by accident: 2.4MB commits kept the main thread busy, so backpressure folded 50 ticks into ~19 commits, skipping 30+ layouts. With commits 30× smaller (post-#1), MT keeps up, every tick gets its own commit and layout, and updateStorm@10k moved 3054 → 3962ms (@30k: ~7.1s → 10.7s, toward the layout floor). Exactly the trap the plan predicted — now recover the win on purpose.

Change

Ack-credit alone is no longer enough (MT acks fast now). Add deliberate pacing:

  1. A commit scheduler in the Lynx transport driver: dispatch at most one commit per main-thread frame (vsync-aligned; on Lynx-for-Web derive from rAF on the MT side or an ack-carried frame token). Renders scheduled between dispatches keep folding via the existing contract — semantics stay "batching", effects fire once per dispatched commit with final state.
  2. First commit after idle always dispatches immediately (point-update latency must not regress — assert select/update10th unchanged).
  3. Make pacing a driver option (commitPacing: 'immediate' | 'frame', default frame), so SSR/electron/universal tests can pin immediate.
  4. Extend the deterministic gates: commands-per-tick stays at the changed-rows floor; add commits-per-storm expectations for paced mode.

Acceptance (rig from #1)

  • updateStorm@10k back to ≤3100ms band (vue-vdom 3175 on the reference host); @30k from 10.7s back toward ~7s.
  • selectStorm holds parity or improves; select/update10th one-shot latency unchanged (first-commit-immediate proof).
  • No effect-ordering or event-scope test regressions; universal suites green.
  • Deterministic: 50-tick storm at pacing=frame dispatches ≈ frames-elapsed commits, not 50.

Activity

  1. Huxpro commented on Aug 9, 2026

    @Huxpro
    OwnerAuthor

    Implemented in PR #10 (stacked on #1's branch). Measured outcome, same host, same instrument, baseline = stack tip e14d6001 vs this diff, back-to-back runs, medians of n=3:

    Wall clock (Lynx for Web, ratios vs vue-vdom measured in the same run):

    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×)

    Against the acceptance criteria:

    • updateStorm@10k ≤3100 band: ratio recovered to 1.07× (from 1.36×) — parity with vue-vdom. The absolute band did not transfer to this host: vue-vdom itself measured 3188/3308 here (not the 3175 reference), so 3524 sits just above 3100 while matching vdom within ~7%. The ratio is the portable claim.
    • @30k toward ~7s: not achieved. Baseline on this host was already 11.5s (not 10.7s), and with pacing both cells moved together (octane 13687 vs vdom 15064; ratio 0.85×→0.91×, overlapping noise bands ±0.8–2.2s). At 30k the main thread is layout-saturated, so unpaced dispatch already folds heavily and pacing has little left to add. Octane stays below vdom at this scale.
    • selectStorm parity or better: 0.87× at 10k (was 1.08×), 0.69× at 30k. selectStorm@1k re-checked at n=5: 598±74 vs baseline 528±175 — unchanged within variance.
    • select/update10th one-shot unchanged: confirmed above; first-commit-after-idle-immediate is pinned by commit-pacing.test.ts.
    • Deterministic commits ≈ frames-elapsed: the paced rig scenario (injected frame source, 1 frame per 2 macrotask turns, 1k rows) dispatches 3 frame-consuming commits for the 50-tick storm (300 commands vs 5000 unpaced), gated by update_storm_paced_frame_commits_1k (red-checked: pacing empty batches again breaches at 2.00×). One caveat pinned honestly in the gates: total commits stay 50 because universal-core re-renders once per scheduled flush after a fold and commits the empty diff — those 47 empty envelopes now cross unpaced (zero frames), and eliding them entirely is the empty-commit-elision item already listed in [lynx-perf 6] Protocol slimming: lazy ack handles, merged completion, empty-commit elision #7 (it needs main-side accepted-version accounting, since main validates call-main/dispose identities against its own accepted version).

    Generated by Claude Code

  2. Huxpro commented on Aug 11, 2026

    @Huxpro
    OwnerAuthor

    Live-main audit (2026-08-11): old implementation rejected; research superseded by #45. The original unconditional protocol no longer fits octanejs#693 compact ACK. Three live-main redesigns were benchmarked: one paid ordinary-message cost, one regressed selectStorm@1k by 50%, and the final isolation was -6.3% forward / +0.2% reverse. Continue only under #45 with real backpressure and zero-command settlement.

  3. Huxpro commented on Aug 11, 2026

    @Huxpro
    OwnerAuthor

    Correction to the closure note: the rejected legacy mechanism was the unconditional frame-pulse protocol. The conclusion and replacement remain unchanged: continue only in #45 with real backpressure and zero-command settlement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions