Skip to content

Conversation

venkyt-arista
Copy link

The sccache client was using Runtime::new() which creates a multi-threaded tokio runtime with worker threads equal to the number of CPU cores. On high-core-count servers running many parallel builds, this created an excessive number of threads.

For example:

  • 96 vCPU server
  • 10 concurrent make invocations
  • Each make using -j16
  • Result: 96 × 10 × 16 = 15,360 threads created by sccache wrappers

While these threads are short-lived, with continuous build pipelines this constant thread creation/destruction causes unnecessary overhead. The sccache client only performs simple I/O operations (connecting to server, sending requests, receiving responses) and doesn't need worker threads.

This change replaces all client-side Runtime::new() calls with Builder::new_current_thread().enable_all().build() to use a single-threaded runtime, reducing thread count from num_cpus to 1 per client invocation.

@venkyt-arista venkyt-arista marked this pull request as draft October 13, 2025 08:59
@venkyt-arista venkyt-arista marked this pull request as ready for review October 13, 2025 09:15
@venkyt-arista venkyt-arista marked this pull request as draft October 13, 2025 20:29
@sylvestre
Copy link
Collaborator

could you please add a test to make sure we don't regress in the future on this? thanks

@codecov-commenter
Copy link

codecov-commenter commented Oct 16, 2025

Codecov Report

❌ Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 59.37%. Comparing base (a888c16) to head (e1aea58).
⚠️ Report is 15 commits behind head on main.

Files with missing lines Patch % Lines
src/commands.rs 83.33% 1 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (a888c16) and HEAD (e1aea58). Click for more details.

HEAD has 5 uploads less than BASE
Flag BASE (a888c16) HEAD (e1aea58)
11 6
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2460       +/-   ##
===========================================
- Coverage   71.62%   59.37%   -12.25%     
===========================================
  Files          65       64        -1     
  Lines       36459    31875     -4584     
===========================================
- Hits        26112    18926     -7186     
- Misses      10347    12949     +2602     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

The sccache client was using Runtime::new() which creates a multi-threaded
tokio runtime with worker threads equal to the number of CPU cores. On
high-core-count servers running many parallel builds, this created an
excessive number of threads.

For example:
- 96 vCPU server
- 10 concurrent make invocations
- Each make using -j16
- Result: 96 × 10 × 16 = 15,360 threads created by sccache wrappers

While these threads are short-lived, with continuous build pipelines this
constant thread creation/destruction causes unnecessary overhead. The sccache
client only performs simple I/O operations (connecting to server, sending
requests, receiving responses) and doesn't need worker threads.

This change replaces all client-side Runtime::new() calls with
Builder::new_current_thread().enable_all().build() to use a
single-threaded runtime, reducing thread count from num_cpus to 1 per
client invocation.
@sylvestre sylvestre force-pushed the venkyt/single-threaded-client branch from e1aea58 to 68adae5 Compare October 16, 2025 11:41
@sylvestre sylvestre requested a review from glandium October 16, 2025 11:41
@venkyt-arista
Copy link
Author

could you please add a test to make sure we don't regress in the future on this? thanks

Will do. Doing a few more tests manually right now. Will add a test before taking this PR out of draft state.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants