Skip to content

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

Merged
sylvestre merged 3 commits into
mozilla:mainfrom
AJIOB:single-threaded-client
Jun 19, 2026
Merged

fix: use single-threaded tokio runtime in sccache (dist-)client#2704
sylvestre merged 3 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.61%. Comparing base (11a89f1) to head (88cb286).

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.64%   74.61%   -0.03%     
==========================================
  Files          70       70              
  Lines       39893    39907      +14     
==========================================
- Hits        29777    29776       -1     
- Misses      10116    10131      +15     

☔ 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 4 times, most recently 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

@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

@AJIOB
AJIOB force-pushed the single-threaded-client branch 3 times, most recently from 8cf2a35 to 4e8ecd9 Compare June 18, 2026 19:14
venkyt-arista and others added 2 commits June 19, 2026 11:20
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.
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 4e8ecd9 to bdfb571 Compare June 19, 2026 08:21
@AJIOB

AJIOB commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

Hi @sylvestre ,

Graceful ping.

CI was green with yesterday evening latest changes

@AJIOB

AJIOB commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

P.S. CI is green

@sylvestre
sylvestre merged commit 27ffc80 into mozilla:main Jun 19, 2026
50 checks passed
@AJIOB
AJIOB deleted the single-threaded-client branch June 19, 2026 11:32
eleboucher pushed a commit to eleboucher/towonel that referenced this pull request Jun 19, 2026
….0) (#36)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [mozilla/sccache](https://github.com/mozilla/sccache) | minor | `0.15.0` → `0.16.0` |

---

### Release Notes

<details>
<summary>mozilla/sccache (mozilla/sccache)</summary>

### [`v0.16.0`](https://github.com/mozilla/sccache/releases/tag/v0.16.0)

[Compare Source](mozilla/sccache@v0.15.0...v0.16.0)

##### sccache 0.16.0

##### Summary

sccache 0.16.0 is a smaller, stabilizing release on top of 0.15.0's multi-tier caching work, with a few new capabilities:

- **Read-only backends**: Any storage backend can now be marked read-only, not just a select few ([#&#8203;2705](mozilla/sccache#2705)).
- **Remote execution on aarch64**: Distributed/remote execution now works on Linux aarch64, including fixes for `ldd` output parsing and toolchain packaging on non-x86\_64 Linux ([#&#8203;2668](mozilla/sccache#2668)).
- **CUDA**: `nvcc`'s `--dependency-output` argument is now handled ([#&#8203;2708](mozilla/sccache#2708)).
- **Resilience**: Fall back to a direct cache write when tempfile creation on the same filesystem fails ([#&#8203;2369](mozilla/sccache#2369)), and give a meaningful error when a multi-level chain references a backend that wasn't compiled in ([#&#8203;2695](mozilla/sccache#2695)).
- **Client efficiency**: The client and dist-client now use a single-threaded tokio runtime, avoiding a thread explosion when many short-lived clients run on many-core hosts ([#&#8203;2704](mozilla/sccache#2704)).
- **Correctness**: Strip `SCCACHE_BASEDIRS` from escaped-backslash paths on Windows ([#&#8203;2736](mozilla/sccache#2736)), ignore empty-set environment values in config ([#&#8203;2639](mozilla/sccache#2639)), and avoid the sccache wrapper when resolving the real compiler ([#&#8203;2720](mozilla/sccache#2720)).
- **Security/logging**: JWT keys and cert digests are now base64-encoded in logs ([#&#8203;2712](mozilla/sccache#2712)), plus general logging improvements ([#&#8203;2734](mozilla/sccache#2734)).

Welcome to 4 new contributors!

##### Features

- feat: all backends support making them as read-only by [@&#8203;AJIOB](https://github.com/AJIOB) in [#&#8203;2705](mozilla/sccache#2705)
- Enable RE on Linux-aarch64 by [@&#8203;malfet](https://github.com/malfet) in [#&#8203;2668](mozilla/sccache#2668)
- feat(nvcc): support argument: `--dependency-output` by [@&#8203;ZRHann](https://github.com/ZRHann) in [#&#8203;2708](mozilla/sccache#2708)
- feat: avoid sccache wrapper when resolving compiler by [@&#8203;iTrooz](https://github.com/iTrooz) in [#&#8203;2720](mozilla/sccache#2720)
- Fall back to direct cache write if tempfile creation on the same fs fails by [@&#8203;myzhang1029](https://github.com/myzhang1029) in [#&#8203;2369](mozilla/sccache#2369)
- Don't wait depfiles for gcc/clang preprocessed inputs by [@&#8203;AJIOB](https://github.com/AJIOB) in [#&#8203;2665](mozilla/sccache#2665)

##### Fixes

- fix: strip SCCACHE\_BASEDIRS from escaped-backslash paths on Windows by [@&#8203;rconde01](https://github.com/rconde01) in [#&#8203;2736](mozilla/sccache#2736)
- fix: ignore empty-set environment values for config by [@&#8203;AJIOB](https://github.com/AJIOB) in [#&#8203;2639](mozilla/sccache#2639)
- fix: handle disabled cache backend features in multilevel chain by [@&#8203;cryptomilk](https://github.com/cryptomilk) in [#&#8203;2695](mozilla/sccache#2695)
- fix: use single-threaded tokio runtime in sccache (dist-)client by [@&#8203;AJIOB](https://github.com/AJIOB) in [#&#8203;2704](mozilla/sccache#2704)
- fix: add newline when printing dist-status to stdout by [@&#8203;iTrooz](https://github.com/iTrooz) in [#&#8203;2710](mozilla/sccache#2710)

##### Logging

- chore: encode jwt key and cert digest with base64 in logs by [@&#8203;iTrooz](https://github.com/iTrooz) in [#&#8203;2712](mozilla/sccache#2712)
- Slightly improve logging by [@&#8203;glandium](https://github.com/glandium) in [#&#8203;2734](mozilla/sccache#2734)

##### Cleanup

- chore: make clippy happy by [@&#8203;AJIOB](https://github.com/AJIOB) in [#&#8203;2727](mozilla/sccache#2727)
- Extract new\_client\_runtime() helper to DRY up client runtime creation by [@&#8203;sylvestre](https://github.com/sylvestre) in [#&#8203;2744](mozilla/sccache#2744)

##### New Contributors

- [@&#8203;ZRHann](https://github.com/ZRHann) made their first contribution in [#&#8203;2708](mozilla/sccache#2708)
- [@&#8203;myzhang1029](https://github.com/myzhang1029) made their first contribution in [#&#8203;2369](mozilla/sccache#2369)
- [@&#8203;malfet](https://github.com/malfet) made their first contribution in [#&#8203;2668](mozilla/sccache#2668)
- [@&#8203;rconde01](https://github.com/rconde01) made their first contribution in [#&#8203;2736](mozilla/sccache#2736)

**Full Changelog**: <mozilla/sccache@v0.15.0...v0.16.0>

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xMDEuMSIsInVwZGF0ZWRJblZlciI6IjQzLjEwMS4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJyZW5vdmF0ZS9naXRodWItcmVsZWFzZSIsInR5cGUvbWlub3IiXX0=-->

Reviewed-on: https://codeberg.org/towonel/towonel/pulls/36
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