← Back to Pull requests

Cap every test's timeout at 60 s #8933

Closed
unknown closed this pull request without merging on Nov 26, 2026 04:55 UTC
View on GitHub
unknown unknown commented on Nov 26, 2026 04:25 UTC
Author

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 (#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

    Diff: 556 lines (+417 / -139) across 6 files Reviewer: jasnell Review duration: 30m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.48) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 556 lines diff across 6 files
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.378
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #8933"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 48.1% (MEDIUM) · Higher = larger blast radius
    48.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.8% · Safe to merge
    20.8%