← Back to Pull requests

scheduling: stop reparsing resource quantities for every worker in Ha… #2016

Closed
unknown closed this pull request without merging on Oct 20, 2026 16:13 UTC
View on GitHub
unknown unknown commented on Sep 30, 2026 19:03 UTC
Author

scheduling: stop reparsing resource quantities for every worker in HasRoom

Fixes the scheduler GC storm and CPU overhead from resource parsing in HasRoom (go/ate-100k).

Problem

Schedule asks HasRoom of every worker in the fleet. On each call, HasRoom parsed three sets of quantity strings into Quantities maps: the actor's limits, the worker's capacity, and the worker's allocation. The limits are identical for every worker in a pass, and capacity and allocation strings repeat across the fleet, yet every call built fresh maps and reparsed everything.

Measured, that was 6 allocations and about 2 KB per worker per placement. A contended resume retries the full fleet scan up to 12 times. At 100k actors this is megabytes of garbage per resume and steady GC pressure on the API server. Quantities that leave the Kubernetes int64 fast path, such as 1.5Gi, additionally drove big.Int arithmetic on every worker.

Change

  • New resources.RoomCheck, built once per placement pass. It parses the actor's size once, reads each worker's capacity and allocation in wire form without building a map, and memoizes every quantity string it sees so a string read on one worker is never parsed again for another. Memoized quantities are normalized to plain int64 form, so slow-path values no longer cause per-worker big.Int arithmetic and share no mutable state between workers.

  • Schedule builds one check for the pass and calls hasRoomWithCheck for each worker.

  • HasRoom keeps its signature and builds a one-shot check, so the admit callback under the store row lock is unchanged.

  • One HasRoom doc comment described unreported dimensions as unconstrained. It now matches the code, which treats them as none of that resource.
  • Diff: 222 lines (+166 / -56) across 2 files Reviewer: Oneimu Review duration: 28630m
    All Vouch review confidence checks passed
    Residual risk 0.15 = Change Risk (0.37) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.37 · 222 lines diff across 2 files
    0.37
    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.323
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #2016"
    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: 36.8% (MEDIUM) · Higher = larger blast radius
    36.8%
    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: 14.5% · Safe to merge
    14.5%