Repository navigation
dist: add load-aware worker capacity - #2899
Open
codeandsolder wants to merge 1 commit into
Open
codeandsolder wants to merge 1 commit into
codeandsolder wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2899 +/- ##
==========================================
+ Coverage 78.54% 79.18% +0.64%
==========================================
Files 74 74
Lines 44039 44553 +514
==========================================
+ Hits 34592 35281 +689
+ Misses 9447 9272 -175 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
codeandsolder-git-wrangler
Bot
force-pushed
the
upstream-pr/load-aware-worker-capacity
branch
5 times, most recently
from
October 17, 2026 01:04
0cdea01 to
53c6507
Compare
codeandsolder-git-wrangler
Bot
force-pushed
the
upstream-pr/load-aware-worker-capacity
branch
from
October 18, 2026 01:16
53c6507 to
4768c93
Compare
codeandsolder-git-wrangler
Bot
force-pushed
the
upstream-pr/load-aware-worker-capacity
branch
from
October 30, 2026 23:53
4768c93 to
d44ee99
Compare
Collaborator
|
The idea is fine, but there's a real bug: the CPU sample covers the previous 30s heartbeat interval, so a worker that just finished a sccache job sees its own compile load and disables itself for 5 minutes. Every other server option lives in server.toml (src/config.rs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Allow an otherwise idle distributed build server to temporarily advertise zero capacity when the host is busy with non-sccache work.
On Linux, setting
SCCACHE_DIST_MAX_HOST_CPU_PERCENTenables aggregate CPU sampling from/proc/stat. When measured busy time exceeds that threshold and the worker is not executing distributed work, its heartbeat advertises zero CPUs.Existing distributed jobs are never interrupted.
Capacity is restored only after CPU usage remains at or below the configured threshold continuously for
SCCACHE_DIST_REENABLE_AFTER_SECONDS(default300).The scheduler accepts zero-capacity registrations and heartbeats, updates an existing server's advertised CPU count, and naturally excludes zero-capacity workers from new allocations.
Scheduler load weighting represents workers that cannot accept another job with
f64::INFINITY, both for zero advertised capacity and for ordinary admission-limit exhaustion. Using a true ineligible sentinel rather than a finite synthetic load keeps scheduler correctness independent of the oversubscription policy: increasing the allowed jobs-per-core ratio in the future cannot make an unavailable worker rank ahead of an eligible higher-load worker.With the option unset, worker behavior is unchanged.
Host-load accounting
The load-aware path is intended to yield to external host work, not to sccache's own CPU use.
To preserve that distinction:
/proc/stat, then measures an initial 100 ms host-load window before HTTP/TLS server and heartbeat startup;/proc/statsample, covering jobs that start or finish around a heartbeat;/proc/statdelta may span the unknown interval.A threshold of
0is well-defined: withdrawal requiresbusy > threshold, while recovery acceptsbusy <= threshold.Capacity withdrawal and restoration are logged at
info!level for operational visibility.Testing
cargo +1.99.0 fmt --all -- --checkcargo +1.99.0 test --locked --no-default-features --features dist-server --bin sccache-dist scheduler_tests::ineligible_load_weights_are_infinite -- --exactcargo +1.99.0 test --locked --no-default-features --features dist-server --bin sccache-dist scheduler_tests::zero_cpu_heartbeat_removes_server_capacity -- --exactAI Disclosure: AI developed, human directed and reviewed