Skip to content

fix: use single-threaded tokio runtime in sccache (dist-)client#2704

Open
AJIOB wants to merge 2 commits into
mozilla:mainfrom
AJIOB:single-threaded-client
Open

fix: use single-threaded tokio runtime in sccache (dist-)client#2704
AJIOB wants to merge 2 commits into
mozilla:mainfrom
AJIOB:single-threaded-client

Conversation

@AJIOB

@AJIOB AJIOB commented May 11, 2026

Copy link
Copy Markdown
Contributor

It's the #2460 follow-up with dist-client similar fixes.

Thanks, @venkyt-arista, for the original fix

@codecov-commenter

codecov-commenter commented May 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 42.85714% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.50%. Comparing base (5d52f91) to head (570df28).

Files with missing lines Patch % Lines
src/commands.rs 60.00% 6 Missing ⚠️
src/dist/client_auth.rs 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2704      +/-   ##
==========================================
- Coverage   74.51%   74.50%   -0.01%     
==========================================
  Files          70       70              
  Lines       39652    39666      +14     
==========================================
+ Hits        29546    29554       +8     
- Misses      10106    10112       +6     

☔ View full report in Codecov by Harness.
📢 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.

@AJIOB AJIOB changed the title Single threaded client fix: use single-threaded tokio runtime in sccache (dist-)client May 11, 2026
@AJIOB AJIOB force-pushed the single-threaded-client branch 2 times, most recently from 15cec8f to 741976e Compare May 17, 2026 14:29
@AJIOB AJIOB force-pushed the single-threaded-client branch 3 times, most recently from a69e52a to ff6010e Compare June 4, 2026 13:34
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.
@AJIOB AJIOB force-pushed the single-threaded-client branch from ff6010e to f02ffc5 Compare June 6, 2026 04:48
@AJIOB

AJIOB commented Jun 6, 2026

Copy link
Copy Markdown
Contributor Author

Hi @sylvestre ,

Is it ok to you?

I don't think we can add some useful testing for that changes.

Comment thread src/dist/client_auth.rs
@sylvestre

Copy link
Copy Markdown
Collaborator

and please udpate the commit message to explain the why

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 dist-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.

The changes are inspired by the previous commit for the classic client.
@AJIOB AJIOB force-pushed the single-threaded-client branch from f02ffc5 to 570df28 Compare June 6, 2026 10:17
@AJIOB

AJIOB commented Jun 6, 2026

Copy link
Copy Markdown
Contributor Author

@sylvestre , done, 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.

4 participants