← Back to Pull requests

Speed up the Python tests in debug and sanitizer builds #8860

Closed
unknown closed this pull request without merging on Nov 25, 2026 20:59 UTC
View on GitHub
unknown unknown commented on Nov 24, 2026 05:06 UTC
Author

The Python tests are among the slowest in the debug and sanitizer builds. Each commit fixes one cause:

  • asgi: the test slept 20 seconds twice to let errors get logged, so it took over 40 seconds in every build, release included. It now waits for the ERROR record itself.

  • durable-object-websocket: the Durable Object never replied to the tester's Close frame, so each run waited 10 seconds for the idle Durable Object to be evicted. The Durable Object now closes its end, and the tester waits for the close event.

  • Liftoff only: V8 tiers Pyodide's hot Wasm functions up to TurboFan on background threads. Most of these tests start from a snapshot and run little Python, so tiering up rarely pays off, while each test is scheduled as one CPU. With --liftoff-only, a workerd run in debug and TSan builds uses 1.3 to 2.5 times less CPU, and its wall time on an idle machine stays about the same. The JSPI and stack-switching tests keep V8's default tiering.

  • worker-loader-python-test: each of its four cases starts Pyodide from scratch in a dynamic Worker. Each case is now a target of its own, selected with workerd test's filter, so they run in parallel, and the test reads the Pyodide bundles from the disk cache that py_wd_test uses rather than downloading them, so it no longer needs network access.

  • 0.26.0a2 variants: 0.26.0a2 can't stack a snapshot on its baseline snapshot, so each 0.26.0a2 variant created its snapshot by starting Pyodide from scratch, over 10 CPU-seconds in debug builds. They now just load the baseline snapshot.

  • Baseline snapshot creation: no test created a baseline snapshot in the newer versions, whose variants stack a dedicated snapshot on the released baseline one. The new top-level-entropy-create-baseline target (create_baseline_snapshot in py_wd_test) starts Pyodide from scratch, creates a baseline snapshot and restores it, in every version.
  • The table compares typical (median) times before this change with the average and worst of 5 runs after it. The "after" runs covered every Python test and variant at once, about 800 runs sharing the executors:

    | | TSan before | TSan after (avg / worst) | debug before | debug after (avg / worst) |
    |---|---|---|---|---|
    | asgi (each version) | 54–60 s | 8–15 s / 23 s | 51–56 s | 8–21 s / 37 s |
    | worker-loader-python-test | 33–36 s | 12–20 s / 43 s per case | 33–34 s | 14–20 s / 58 s per case |
    | durable-object-websocket | 20–23 s | 8–11 s / 16 s | 20–21 s | 13–17 s / 29 s |
    | slowest Python test | | 22 s / 33 s | | 28 s / 52 s |

    Loading the baseline snapshot halved the 0.26.0a2 variants, measured in a separate 5-run pass: debug average 19.9 s → 10.0 s, worst run 26.9 s → 15.9 s; TSan average 14.7 s → 9.2 s. top-level-entropy-create-baseline averages 20–26 s per version in debug builds and 15–27 s in TSan over 5 runs; the worker-loader-python-test figures come from the same, more heavily loaded pass, in which even hello_0.28.2 (about 7 s on an idle executor) had runs of over 30 s.

    🤖 Generated with Claude Code

    Diff: 386 lines (+289 / -97) across 4 files Reviewer: hoodmane Review duration: 2392m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.43) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 386 lines diff across 4 files
    0.43
    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.356
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #8860"
    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: 43% (MEDIUM) · Higher = larger blast radius
    43%
    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: 18.6% · Safe to merge
    18.6%