← Back to Pull requests

Hand out a worker that has run a task before one that has not #456

Closed
unknown closed this pull request without merging on Nov 30, 2026 18:57 UTC
View on GitHub
unknown unknown commented on Nov 30, 2026 11:33 UTC
Author

With idle_timeout, a worker that has just been started goes to the front of the idle queue, so the next task can be given one that is still starting while warm ones are idle. This keeps a worker that has run nothing behind those that have.

Measured with three workers, a 2 s start-up, recycling after two tasks, and one task at a time: on main, the third and fifth of six tasks waited 1.9 s each. With this change none waits.

What changes, only with idle_timeout and min_workers:

  • A worker that has run a task is handed out before one that has not. Among workers that have run a task, the most recently used still goes first.

  • The longest-idle worker still retires first. The queue is no longer in age order, so the timer now picks the oldest by its timestamp. Looking only at the front would let a new worker hide expired ones behind it until it expired too.
  • A worker that has run nothing waits behind even if it finished starting long ago, so it is used only when no other is idle.

    Tests: a task is not given a worker held in its initializer while a warm one is idle, and a new worker does not stop expired ones from retiring. The first fails on main; the second fails if the timer looks only at the front. The full suite passes on Python 3.10 to 3.14 and on 3.14t with the GIL off (226 each).

    Diff: 165 lines (+123 / -42) across 2 files Reviewer: cjrh Review duration: 443m
    All Vouch review confidence checks passed
    Residual risk 0.14 = Change Risk (0.35) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.35 · 165 lines diff across 2 files
    0.35
    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.306
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #456"
    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: 35% (MEDIUM) · Higher = larger blast radius
    35%
    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: 13.8% · Safe to merge
    13.8%
    Repository