Skip to content

client-side: run each compile on a current-thread runtime - #2997

Merged
sylvestre merged 1 commit into
mozilla:mainfrom
sylvestre:pr/client-current-thread-runtime
Nov 20, 2026
Merged

sylvestre merged 1 commit into
mozilla:mainfrom
sylvestre:pr/client-current-thread-runtime

Conversation

@sylvestre

Copy link
Copy Markdown
Collaborator

A client-side invocation built a multi-thread Tokio runtime with two workers, which it then mostly waits on: the compile runs in a child process and cache I/O goes over IPC. Starting those threads in every invocation costs about 1.3ms per cache hit (13.6ms to 12.3ms, one hit at a time, on an FFmpeg source file whose server-mode hit takes 8ms).

Use the current-thread runtime that server-mode clients already use. Blocking work still goes to the blocking thread pool.

@codecov-commenter

codecov-commenter commented Nov 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.39%. Comparing base (6f6e390) to head (37730ef).

❗ There is a different number of reports uploaded between BASE (6f6e390) and HEAD (37730ef). Click for more details.

HEAD has 8 uploads less than BASE
Flag BASE (6f6e390) HEAD (37730ef)
14 6
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2997      +/-   ##
==========================================
- Coverage   79.00%   72.39%   -6.61%     
==========================================
  Files          75       75              
  Lines       46249    44746    -1503     
==========================================
- Hits        36538    32395    -4143     
- Misses       9711    12351    +2640     

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

@ahochheiden ahochheiden left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, just one small simplification.

Comment thread src/commands.rs Outdated
Comment on lines +1015 to +1020
let conn = connect_or_start_server(&get_addr(), startup_timeout)?;
if config.client_side_mode {
// Under make -jN each CLI process gets only 2 worker threads;
// one for preprocessing/compilation and one for IPC. The
// blocking thread pool absorbs zstd/zip work.
let mut runtime = Builder::new_multi_thread()
.worker_threads(2)
.enable_all()
.build()?;
// One compile needs no worker threads of its own: starting two
// in every invocation cost about 1ms per cache hit. The
// blocking thread pool still absorbs zstd/zip work.
let mut runtime = new_client_runtime()?;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can move this outside the if and get rid of the same call on line 1035 below, since both branches build the same runtime now.

Suggested change
let conn = connect_or_start_server(&get_addr(), startup_timeout)?;
if config.client_side_mode {
// Under make -jN each CLI process gets only 2 worker threads;
// one for preprocessing/compilation and one for IPC. The
// blocking thread pool absorbs zstd/zip work.
let mut runtime = Builder::new_multi_thread()
.worker_threads(2)
.enable_all()
.build()?;
// One compile needs no worker threads of its own: starting two
// in every invocation cost about 1ms per cache hit. The
// blocking thread pool still absorbs zstd/zip work.
let mut runtime = new_client_runtime()?;
let conn = connect_or_start_server(&get_addr(), startup_timeout)?;
let mut runtime = new_client_runtime()?;
if config.client_side_mode {

A client-side invocation built a multi-thread runtime with two workers,
which it then mostly waited on: the compile runs in a child process and
cache I/O goes over IPC. Starting those threads in every invocation made
a cache hit 1.3ms slower (13.6ms to 12.3ms per hit, one at a time, for a
file whose server-mode hit takes 8ms).

Use the current-thread runtime server mode clients already use. Blocking
work still goes to the blocking thread pool.
@sylvestre
sylvestre force-pushed the pr/client-current-thread-runtime branch from 476b5b5 to 37730ef Compare November 20, 2026 08:41
@sylvestre
sylvestre marked this pull request as ready for review November 20, 2026 13:15
@sylvestre
sylvestre merged commit 1616af1 into mozilla:main Nov 20, 2026
51 checks passed
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