Skip to content

test(octane): let drainProducers run host-budget yields - #1920

Merged
trueadm merged 2 commits into
mainfrom
test/signals-drain-host-tasks
Oct 8, 2026
Merged

trueadm merged 2 commits into
mainfrom
test/signals-drain-host-tasks

Conversation

@trueadm

@trueadm trueadm commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • drainProducers() in tests/_fixtures/signals-async-controls.ts now runs four rounds. Each round is a setImmediate followed by a task posted with the runtime's own postHostTask. Before, it waited for one setImmediate.
  • Test-only. Runtime behavior and the 5 ms budget are unchanged, so there is no changeset.

Why

  • Since fix: coalesce and pace ready signal producers #1875, ready signal producers share one 5 ms window per host (yieldForHostBudget in src/host-budget.ts). Once the window is spent, a producer waits for a host task. A single setImmediate doesn't reliably cover that wait, so on a slow or loaded shard a test can read a pending value ("Unknown Error: Promise") or a stale one.
  • perf(octane): render hookless control-flow arms without a Block #1903 hit this twice in shard 2/4 in signals-serialization.test.ts, after its new test file reshuffled the CI shards. It fixed only that file's local drain(). The same latent failure exists in every suite that settles through drainProducers, so this fixes it in the shared helper rather than per test.
  • Each round lets at least one parked producer continue. A forced budget of 1e-9 ms admits only one unit per window, which is the worst case any host can produce. Three rounds is the minimum that passes every suite under that budget; four leaves one round of margin.

Validation

Reproduced by temporarily setting HOST_BUDGET_MS = 1e-9 in host-budget.ts, which this PR leaves at 5.

  • Old helper, budget 1e-9: these failed.
    • signals-inspection "reports stream activity and retained quiet refresh without exposing payloads" (octane-signals-node).
    • Three signals-streams cases (octane-signals-node): "does not cancel a data-owned stream when its last public subscription stops", and "reports a throwing iteration-result done getter" / "value getter through the resource".
    • Two signals-unified cases, in both octane-signals and octane-signals-prod: "publishes stream yields and closes an obsolete iterator" and "keeps a selected watch live after adopting an action receipt".
  • New helper, budget 1e-9:
    • octane-signals-node, octane-signals, octane-signals-prod, octane-signals-strong: 1270/1272 passed. The 2 remaining failures are the signals-serialization stream-adoption cases. They use that file's own drain(), which perf(octane): render hookless control-flow arms without a Block #1903 fixes (e7fb961), so this PR leaves that file alone.
    • The other drainProducers users (7 hydration files plus compiler/signal-attempt-reads) in octane + octane-prod: 1499/1499 passed.
  • New helper, budget restored to 5: the four signals projects passed 1272/1272, and the hydration/compiler users passed 1499/1499.
  • Rounds sweep under 1e-9 across the three affected files: 1 round leaves 7 failures, 2 rounds leave 1, 3 rounds pass.
  • pnpm format:files:check and pnpm typecheck:files on the fixture
  • pnpm format:check / pnpm typecheck / pnpm test: not run in full locally; CI covers them.
  • targeted tests: as above.
  • perf-review: not applicable. The diff is test-only and touches no packages/octane/src, compiler output, or binding hot path.
  • concise-code: src +0 −0 (runtime +0 −0). No new files or exports. It reuses postHostTask instead of adding another MessageChannel copy.
    • Rejected: per-test fixes in the six failing tests (more lines, and the hazard stays latent for every other drainProducers caller).
    • Rejected: pinning performance.now per test (hides the yield path the tests would meet on a slow host).
    • Bytes: not applicable.

Risk / follow-ups

Provenance

  • An agent produced this diff (agent-authored)

🤖 Generated with Claude Code


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


Note

Low Risk
Test fixture only; no production runtime, compiler, or binding changes.

Overview
Test-only: shared helper drainProducers() in signals-async-controls.ts no longer flushes producer work with a single setImmediate. It now runs four rounds, each awaiting setImmediate and then a runtime postHostTask callback.

That matches how ready signal producers resume after yieldForHostBudget once the per-host 5 ms window is spent, so signal/hydration/compiler tests that call drainProducers() stop flaking on slow or loaded CI shards (stale reads / "Unknown Error: Promise"). Runtime and host budget are unchanged.

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

Since #1875 a ready producer whose shared 5 ms host budget is spent waits
for a host task (yieldForHostBudget). drainProducers() waited for a single
setImmediate, so on a loaded CI shard a stream step could still be parked
behind that task and the test saw a pending or stale value. It now runs four
rounds of setImmediate plus a postHostTask task, so each round lets at least
one parked producer continue.

With the budget forced to 1e-9 ms (one unit per window), the old helper
failed signals-inspection's stream-activity case, three signals-streams
cases, and two signals-unified cases in both octane-signals and
octane-signals-prod; three rounds is the minimum that passes them all.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent test PR: tests only labels Oct 8, 2026
@trueadm
trueadm marked this pull request as ready for review October 8, 2026 20:15
@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark report

🟢 No byte growth, no added work, and no timing changes beyond ±3%.

Compares 6e6aa98f6, the merge commit's first parent with 19fd32252 on the same runner. Any increase in a js-framework work counter fails this check; byte changes are a report. Wall time is a report: base and head samples alternate in one browser, and an operation is called slower or faster only when the 95% confidence interval of its ratio excludes ±3%. Workflow run

js-framework: 1k/10k row operations

All 20 timed operations (20 without a verdict)
target operation base ms head ms head/base 95% CI
octane-tsrx run 3.650 3.008 ±0.0% −3.3% … +3.0% ⚪ within noise
octane-tsrx replace 6.250 6.125 −0.0% −2.3% … +1.3% ⚪ within noise
octane-tsrx add 2.667 2.617 −1.8% −5.2% … ±0.0% ⚪ within noise
octane-tsrx update 0.155 0.188 +0.6% −4.3% … +7.3% ⚪ within noise
octane-tsrx select 0.009 0.011 +0.6% −3.3% … +6.1% ⚪ within noise
octane-tsrx swap 0.063 0.060 +6.3% −0.8% … +16.3% ⚪ within noise
octane-tsrx remove 0.022 0.018 −0.4% −54.6% … +5.6% ⚪ within noise
octane-tsrx runlots 35.708 40.542 +0.2% −2.4% … +1.7% ⚪ within noise
octane-tsrx select_lots 0.008 0.010 −1.8% −9.4% … +5.4% ⚪ within noise
octane-tsrx clear 55.958 44.375 −6.2% −15.4% … +3.2% ⚪ within noise
octane-jsx run 6.875 6.200 ±0.0% −16.2% … +7.7% ⚪ within noise
octane-jsx replace 9.708 10.533 −0.1% −7.7% … +6.6% ⚪ within noise
octane-jsx add 3.750 3.967 ±0.0% −3.8% … +2.7% ⚪ within noise
octane-jsx update 0.381 0.412 +5.0% −1.1% … +9.8% ⚪ within noise
octane-jsx select 0.168 0.173 ±0.0% −8.8% … +10.9% ⚪ within noise
octane-jsx swap 0.354 0.329 +2.5% −17.0% … +7.2% ⚪ within noise
octane-jsx remove 0.274 0.265 −6.2% −40.1% … +2.8% ⚪ within noise
octane-jsx runlots 68.158 70.175 +2.8% −2.6% … +46.6% ⚪ within noise
octane-jsx select_lots 4.021 3.642 −4.8% −20.0% … +7.8% ⚪ within noise
octane-jsx clear 60.450 62.792 +2.2% −6.9% … +6.5% ⚪ within noise

All 64 work counters are unchanged.

Application bundle size (bytes)

No changes across 60 measured values.

Public-import reachability bundles (bytes)

No changes across 111 measured values.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
octane-website c7930e6 Commit Preview URL

Branch Preview URL
Oct 08 2026, 08:44 PM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
octane-website-mcp c7930e6 Commit Preview URL

Branch Preview URL
Oct 08 2026, 08:46 PM

@trueadm
trueadm merged commit 5f0c511 into main Oct 8, 2026
28 of 29 checks passed
@trueadm
trueadm deleted the test/signals-drain-host-tasks branch October 8, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent test PR: tests only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant