← Back to Pull requests

fix(scheduler): stop builds queueing behind an in-flight compile they cannot reuse #859

Closed
unknown closed this pull request without merging on Oct 28, 2026 15:58 UTC
View on GitHub
unknown unknown commented on Oct 28, 2026 10:43 UTC
Author

When many builds compile the same crate from different checkouts, they could queue behind one another for many minutes with no message. A build that finds another build already compiling the same invocation waits for it (an "in-flight" compile). If the finished result did not match its own inputs, the waiter compiled anyway, but while still holding the in-flight lock, so the next waiter waited for that compile too. On a busy host, single waits of 5 to 40 minutes were seen. Inside the waiting container there was no compiler process, so the wait looked like a hang.

Now:

  • A waiting build releases the in-flight lock before compiling when the first build's newly published result does not match its own files. Builds with different inputs then compile in parallel through the normal permit pool. When the first build failed or was killed and left nothing, the next waiter still compiles while holding the lock, so the others can reuse its result. A waiter recognizes the first build's result by an attempt id that build wrote when it took the lock. So a result published before the waiter arrived counts too, and builds without an id fall back to holding the lock.

  • After 60 seconds of waiting, mbx prints a warning that names the crate (or the C/C++ compilation).

  • A build stops waiting after 10 minutes, or four times the last recorded compile time if that is longer, and then compiles on its own.

  • A build that released the lock also skips the remote cache's join promise, which could otherwise wait up to an hour.
  • This applies to both the Rust and the C/C++ compiler wrappers. docs/how-it-works.md describes the waits.

    Tests: a new integration test holds a real compiler mid-compile. It checks that a third build can take the lock while a mismatched waiter compiles, and cannot when the first build left nothing; it fails without the release. Scheduler unit tests cover change detection (including a result published before the waiter arrives), release, the one-time warning and the limit. The integration test's compiler wrapper is released, and its process group killed, on every exit path.

    Soak: on a 96-core workstation whose cache and targets are on ZFS, in a build combining this change with the other pending fixes, from 2026-10-27 23:01Z to 2026-10-28 08:01Z, under normal agent and benchmark load. Four checks and 23 snapshots found no regression attributable to the build. The window was interrupted by a host reboot. This change had already been running on two hosts since 2026-10-27 13:15Z. In the combined soak, no in-flight wait exceeded the 600 s bound (longest 371 s). The long-wait tail rose and fell with host load, from 0.26 to 27 waits over 60 s per 1,000 compiles.

    AI-assisted — Tool: Claude Code; model: anthropic/claude-opus-5-5; version: 2.1.306.

    🤖 Generated with Claude Code

    Diff: 357 lines (+267 / -90) across 4 files Reviewer: jbellis Review duration: 315m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 357 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%
    60%
    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.352
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #859"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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: 42.6% (MEDIUM) · Higher = larger blast radius
    42.6%
    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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 16.8% · Safe to merge
    16.8%