feat(scheduler): budget CPU and memory separately #750
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #750"
general
weight: 0.35
jbellis
Builds on #748 (merged), which lets queued builds share capacity they cannot use yet.
mbx's scheduler charged every compile, link, and test run a single number of permits: the larger of its thread count and its predicted memory divided by
scheduler.memory / scheduler.cpus. So one number stood for both CPU and memory. A compile that needs 13 GiB but keeps only one or two cores busy took 17 permits. Each permit also stands for one core, so the other 15 or so cores it was charged for sat idle while CPU-light requests waited.This change gives the scheduler separate budgets for CPU cores and for memory bytes:
-j, constrains cores only.mbx reserve --cpus N --memory Mnow reserves exactly N cores and M bytes, instead of the larger of the two as permits.mbx stats --schedulerand the observation log show cores and memory charged.The settings are unchanged. Their descriptions now say that
scheduler.cpusandscheduler.reserve_cpusset a core budget, andscheduler.memorysets an independent memory budget.Measured effect. These figures come from a replay of 6,873 admissions recorded by mbx's observation log on a shared build host over about 3.3 hours. The replay keeps the recorded arrival and run times and models a single scope.
| Policy | Total wait (request-hours) | p95 wait | p99 wait |
|---|---:|---:|---:|
| Single permit budget, today's ordering | 55.3 | 207 s | 286 s |
| Separate budgets, today's ordering | 46.6 | 200 s | 253 s |
| Single permit budget, #748 | 22.6 | 79 s | 121 s |
| Separate budgets, #748 | 14.8 | 57 s | 81 s |
The modelled baseline accounts for only part of the waiting actually recorded (correlation 0.85), and the model charges exact bytes, where today's permits round up by about 2%. So read these figures as a comparison between policies, not as a forecast.
Compatibility. Lease and waiting records gain explicit core and memory fields. They keep the old fields, computed exactly as before, and a test checks 168 demand and configuration cases against the previous code.
Known behavior: a compile is charged its thread count, but rustc can use more threads during code generation through Cargo's jobserver. With memory no longer taking up CPU permits, more small compiles can run alongside large ones, so the host's CPUs can be oversubscribed. That slows compiles but does not cause out-of-memory kills.
Validation:
cargo clippy -p mbx --all-targets --all-features -- -D warnings, andcargo fmt --check;usagegenerator and the options frommise.toml, because mise was not available locally;cli::pretty::tests::mascot_keeps_progress_readable_and_leaves_successful_builds,materialize::materialization_tests::a_restore_stamp_is_never_ahead_of_a_write_that_follows_it, andmaterialize::materialization_tests::a_filesystem_without_clones_links_the_object_instead_of_copying_it. These are renderer and filesystem-timing tests, run on a heavily loaded host.An independent review compared the code with the previous commit using the exact functions from both. It found one mixed-version problem: the container-limit field in waiting records had changed meaning. A second mixed-version problem came from review on this PR: older waiters were not protected by their own single-number rule. Both are fixed here, with regression tests.
The full
mise run cigate was not run locally.AI-assisted — Tool: Claude Code; model: Anthropic/claude-opus-5-5; version: 2.1.302.
AI-assisted — Tool: Codex; model: OpenAI/gpt-6.1-sol; version: unavailable.
🤖 Generated with Claude Code
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
Summary by CodeRabbit
New Features
The scheduler now budgets CPU cores and memory independently, admitting work based on both available resources.
Workload history and memory measurements help estimate resource needs; unmeasured work uses defaults.
Scheduler reports show separate CPU and memory charges. Reservations can specify CPU and memory independently.
Low-priority work leaves headroom in both budgets for normal-priority work.
Setting
scheduler.memoryto"none"enables CPU-only scheduling.Documentation
Updated configuration and scheduling guides to explain resource budgets, estimates, reservations, and admission behavior.
mbx reserve --cpusnow describes the reserved amount in CPU cores.<!-- end of auto-generated comment: release notes by coderabbit.ai -->