Skip to content

Cap every test's timeout at 60 s - #8933

Merged
danlapid merged 4 commits into
mainfrom
dlapid/workerd-test-timeout-60s
Nov 26, 2026
Merged

danlapid merged 4 commits into
mainfrom
dlapid/workerd-test-timeout-60s

Conversation

@danlapid

@danlapid danlapid commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Caps every test's Bazel timeout at 60 s, and speeds up the tests that went over it or came close.

Every test should finish within 40 s in every CI config, sanitizers included, so a test that reaches 60 s has hung or regressed. Today CI waits up to 240 s for an enormous test, up to 2,400 s under TSan and 240 s under coverage before it reports one.

Timeouts (small, medium, large, enormous)

Config Before After
Default (also ASan and Windows) 3, 15, 60, 240 3, 15, 60, 60
TSan 30, 150, 600, 2400 30, 60, 60, 60
macOS cross-compile to x86_64 1, 30, 60, 240 1, 30, 60, 60
Coverage 240 for every size 60 for every size
PGO training (pgo-instrument) 30, 240, 600, 1200 unchanged

PGO training keeps its longer timeouts: it collects profiles rather than checking changes, its serving workload takes about a minute, and a test that times out loses its profile. Tests with timeout = "eternal" now get 60 s too; cron-test, the one that runs in CI, takes about 25 s.

Tests made faster here

Test Before (TSan unless noted) After (TSan unless noted, bazelflare)
repl-test: 4 shards, every fourth case each 52-74 s max 17 s (20 runs)
wpt:WebCryptoAPI: 8 → 16 shards shards ~20 s, 40-60 s on slow executors, once 104 s p50 10 s, max 26 s (5 runs × 16 shards)
wpt:encoding, wpt:encoding-ts: 4 shards each ~25 s, 50-82 s on slow executors max 12 s (5 runs)
container-client (all 3 variants): 8 shards, every eighth case each 92-155 s, default config (test-linux) max 30.5 s, default config (5 runs × 8 shards)
scheduler-test (all 3 variants): sequentialAbort fills the timeout quota first 58-159 s max 4.8 s (5 runs)

All of them also pass in the default config; the WPT suites and repl-test in ASan too.

workerd test can't divide a config's entrypoints between Bazel shards, so container-client's test module wraps its own cases: a shard runs every TEST_TOTAL_SHARDS-th case in name order and the rest pass at once. The shard variables reach the worker through fromEnvironment bindings, which are null outside Bazel, so a plain run still runs every case.

sequentialAbort checked that aborting a scheduler.wait frees its slot in the 10,000-timeout quota by aborting 11,000 waits. Each abort throws an exception, about 5 ms under TSan against 0.2 ms in a fastbuild, and most of that looks like KJ capturing the exception's stack trace (any KJ exception costs about the same; switching KJ to _Unwind_Backtrace raises it to 12 ms). The test now fills all but one slot with waits that never end, checks the quota is full, and waits and aborts 100 times in the last slot. With the cleanup in Scheduler::wait() removed, it fails on the second wait.

How I measured

Per-test process wall time from the Bazel profiles of the Tests workflow, over the 6 runs on main and 33 pull request runs since #8853-#8863 landed (2026-11-25 21:00 UTC onward), leaving out 3 pull request runs that tested an older base. The linux-arm jobs' profiles carry almost no per-test times, so their numbers come from the progress lines of 44 job logs each, which also count time spent waiting for a local CPU and so overstate. Coverage keeps no per-test timings in CI and its results on main are cache hits, so I ran the coverage job's targets once, uncached, on bazelflare.

Expected state of CI

No test I know of goes over the cap now. These came close, but stayed under it in a normal run:

  • Windows, in runs where the runner's disk saturates (Don't sync SQLite on Windows disk when the VFS says not to #8911): tests running at the same time slow down together. In one run every server-test shard took 43-61 s (already a large test, with the same 60 s as before). cron-test p50 25 s, max 50 s. d1-test, workflows-test, sql-test and kv-test each reached 43-47 s once.
  • TSan and ASan on a slow executor: single runs where many tests are 2-5x slower than usual, such as one TSan run where every server-test@all-autogates shard took 56-184 s, one ASan run with server-test shards at 42-54 s, and pyodide vendor tests at 40-62 s under TSan.
  • linux-arm debug: server-test@all-autogates shards up to about 41 s (log progress, an overestimate).
  • Linux release, macOS, linux-arm release and coverage: nothing else over 40 s. The slowest coverage test took 24 s.

🤖 Generated with Claude Code

danlapid and others added 2 commits November 25, 2026 23:20
Under TSan, repl-test took 52-74 s: each of its 27 cases starts
workerd, which takes about two seconds there. It now runs as 4 shards,
each running every fourth case; the slowest shard took 17 s in 20 TSan
runs.

wpt:WebCryptoAPI's 8 shards took about 20 s each under TSan, and
40-60 s on a slow executor in many CI runs. With 16 shards the slowest
took 26 s in 5 TSan runs (p50 10 s). wpt:encoding and wpt:encoding-ts
took about 25 s under TSan, and 50-80 s on a slow executor; as 4
shards each they took at most 12 s in 5 TSan runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every test should finish within 40 s in every CI config, sanitizers
included, so a test that reaches 60 s has hung or regressed. The cap
makes CI report it after 60 s rather than after up to 240 s (default
enormous), 600-2400 s (TSan large and enormous) or 240 s (coverage).

- Default: 3,15,60,240 -> 3,15,60,60. This also covers ASan and
  Windows, which use the default.
- TSan: 30,150,600,2400 -> 30,60,60,60.
- macOS cross-compile to x86_64: 1,30,60,240 -> 1,30,60,60.
- Coverage: 240 for every size -> 60. In an uncached run of the
  coverage job's 1,423 tests on bazelflare, the slowest took 24 s.
- PGO training (pgo-instrument) keeps its longer timeouts: it collects
  profiles rather than checking changes, its serving workload takes
  about a minute, and a test that times out loses its profile.

Tests with `timeout = "eternal"` now also get 60 s; cron-test, the one
that runs in CI, takes about 25 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
danlapid and others added 2 commits November 25, 2026 23:32
Each of its 61 cases starts containers, about two seconds' worth, so
the test took 110 s on bazelflare and 92-155 s in CI: over the 60 s
cap. `workerd test` can't divide a config's entrypoints between
shards, so the test module wraps its own cases instead: each shard
runs every TEST_TOTAL_SHARDS-th case in name order, and the rest pass
at once. The shard variables reach the worker through fromEnvironment
bindings, which are null outside Bazel, so a plain run still runs
every case.

With 8 shards the slowest shard took 23 s on bazelflare.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sequentialAbort aborted 11,000 waits to check that an abort frees its
slot in the quota of 10,000 active timeouts. Each abort throws an
exception, which costs about 5 ms under TSan, so the test took 58-159
s there, over the 60 s cap.

It now fills all but one slot with waits that never end, checks that
the quota is then full, and waits and aborts 100 times in the last
free slot, so a single leaked slot makes the next wait fail. With the
cleanup in Scheduler::wait() removed, it fails on the second wait.
Under TSan it takes at most 5 s on bazelflare.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@danlapid
danlapid marked this pull request as ready for review November 26, 2026 04:46
@danlapid
danlapid requested review from a team as code owners November 26, 2026 04:46

@clanky-the-clanker clanky-the-clanker Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Approved — I found no correctness, security or performance problems. The timeout cap and the sharding changes are consistent with the existing Bazel test macros.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🔒 Security: ✅ LGTM

This pull request changes only test configuration and test code.


📖 AGENTS.md: ✅ LGTM

No changes to AGENTS.md are needed.


📋 Code Quality: ✅ LGTM

The container-client and repl-test sharding wrappers are correct and fall back to running every case outside Bazel. The new sequentialAbort still checks the abort cleanup in Scheduler::wait() against the 10,000-timeout quota.


⚡ Performance: ✅ LGTM

Only test timeouts, shard counts and test code change. Nothing here affects runtime performance.


📝 Documentation: ✅ LGTM

The new comments describe the current behaviour of the code.


Reviewed commit: 5f61210e

@danlapid
danlapid enabled auto-merge November 26, 2026 04:52
@danlapid
danlapid merged commit 15f1804 into main Nov 26, 2026
25 checks passed
@danlapid
danlapid deleted the dlapid/workerd-test-timeout-60s branch November 26, 2026 04:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants