Skip to content

Take first task group for further execution#154419

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
zetanumbers:take-first-group
Mar 31, 2026
Merged

Take first task group for further execution#154419
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
zetanumbers:take-first-group

Conversation

@zetanumbers
Copy link
Copy Markdown
Contributor

@zetanumbers zetanumbers commented Mar 26, 2026

Continuing from #153768 (comment).

I thought that storing a first group of tasks for immediate execution instead of pushing and immediately poping it from rayon's local task queue in par_slice would avoid overwhelming work stealing potentially blocking the original thread. So I've implemented this change.

8 threads benchmarks:

Benchmarkbaseline~~9new~take-first-group~1
TimeTime%
🟣 hyper:check0.1110s0.1086s💚 -2.13%
🟣 hyper:check:initial0.1314s0.1298s💚 -1.23%
🟣 hyper:check:unchanged0.0771s0.0755s💚 -2.14%
🟣 clap:check0.3787s0.3757s -0.80%
🟣 clap:check:initial0.4680s0.4564s💚 -2.48%
🟣 clap:check:unchanged0.2337s0.2301s💚 -1.52%
🟣 syn:check0.4321s0.4265s💚 -1.31%
🟣 syn:check:initial0.5586s0.5401s💚 -3.31%
🟣 syn:check:unchanged0.3434s0.3429s -0.14%
🟣 regex:check0.2755s0.2661s💚 -3.40%
🟣 regex:check:initial0.3350s0.3347s -0.11%
🟣 regex:check:unchanged0.1851s0.1832s💚 -1.01%
Total3.5296s3.4695s💚 -1.70%
Summary1.0000s0.9837s💚 -1.63%

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 26, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 26, 2026

r? @jieyouxu

rustbot has assigned @jieyouxu.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 69 candidates
  • Random selection from 11 candidates

@lqd
Copy link
Copy Markdown
Member

lqd commented Mar 26, 2026

I wonder what variance, and noise level, you're seeing on your benchmarking machine? BTZ, does this remove some small overhead a few times, or does it translate to good results on bigger benchmarks as well?

@jieyouxu
Copy link
Copy Markdown
Member

@rustbot reroll

@rustbot rustbot assigned nnethercote and unassigned jieyouxu Mar 26, 2026
@zetanumbers
Copy link
Copy Markdown
Contributor Author

zetanumbers commented Mar 26, 2026

I wonder what variance, and noise level, you're seeing on your benchmarking machine? BTZ, does this remove some small overhead a few times, or does it translate to good results on bigger benchmarks as well?

Here's baseline compiler running against itself:

Benchmarkbaseline~~9baseline~~9
TimeTime%
🟣 hyper:check0.1143s0.1157s💔 1.25%
🟣 hyper:check:initial0.1405s0.1420s💔 1.08%
🟣 hyper:check:unchanged0.0805s0.0797s💚 -1.02%
🟣 clap:check0.3914s0.3909s -0.14%
🟣 clap:check:initial0.4765s0.4823s💔 1.21%
🟣 clap:check:unchanged0.2345s0.2329s -0.68%
🟣 syn:check0.4328s0.4303s -0.58%
🟣 syn:check:initial0.5820s0.5731s💚 -1.53%
🟣 syn:check:unchanged0.3695s0.3696s 0.02%
🟣 regex:check0.2668s0.2720s💔 1.95%
🟣 regex:check:initial0.3224s0.3289s💔 2.02%
🟣 regex:check:unchanged0.1901s0.1846s💚 -2.92%
Total3.6015s3.6021s 0.02%
Summary1.0000s1.0006s 0.06%

I have run these benchmarks on various changes before and never seen all greens like above.

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 27, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@Zoxc
Copy link
Copy Markdown
Contributor

Zoxc commented Mar 30, 2026

I wasn't able to reproduce the improvements. Perhaps different scheduling on Windows is the cause? The change seems unlikely to be a regression anyway.

Results with 7 threads:

BenchmarkBeforeBeforeAfterBeforeBeforeAfterBeforeBeforeAfter
TimeTime%Time%Physical MemoryPhysical Memory%Physical Memory%Committed MemoryCommitted Memory%Committed Memory%
🟣 clap:check0.3963s0.3965s 0.04%0.3979s 0.40%204.25 MiB204.22 MiB -0.01%204.14 MiB -0.05%276.78 MiB276.56 MiB -0.08%276.79 MiB 0.00%
🟣 hyper:check0.1318s0.1308s -0.80%0.1309s -0.69%127.65 MiB127.66 MiB 0.01%127.60 MiB -0.03%195.84 MiB195.82 MiB -0.01%195.83 MiB -0.00%
🟣 regex:check0.2722s0.2726s 0.13%0.2726s 0.15%167.22 MiB167.32 MiB 0.06%167.29 MiB 0.04%227.83 MiB227.85 MiB 0.01%227.92 MiB 0.04%
🟣 syn:check0.5073s0.5070s -0.06%0.5060s -0.27%197.98 MiB198.04 MiB 0.03%198.09 MiB 0.06%259.91 MiB260.00 MiB 0.03%260.03 MiB 0.04%
Total1.3077s1.3068s -0.07%1.3074s -0.02%697.10 MiB697.23 MiB 0.02%697.12 MiB 0.00%960.37 MiB960.23 MiB -0.01%960.57 MiB 0.02%
Summary1.0000s0.9983s -0.17%0.9990s -0.10%1 byte1.00 bytes 0.02%1.00 bytes 0.00%1 byte1.00 bytes -0.01%1.00 bytes 0.02%

@Zoxc
Copy link
Copy Markdown
Contributor

Zoxc commented Mar 30, 2026

I did a benchmark run with 7 threads in a Linux VM and that does look like an improvement:

BenchmarkBeforeBeforeAfter
TimeTime%Time%
🟣 regex:check0.2905s0.2895s -0.33%0.2877s -0.95%
🟣 hyper:check0.1317s0.1307s -0.76%0.1295s💚 -1.71%
🟣 clap:check0.4345s0.4347s 0.06%0.4299s💚 -1.05%
🟣 syn:check0.5256s0.5248s -0.15%0.5209s -0.90%
Total1.3823s1.3798s -0.18%1.3680s💚 -1.03%
Summary1.0000s0.9970s -0.30%0.9885s💚 -1.15%

@nnethercote
Copy link
Copy Markdown
Contributor

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot pushed a commit that referenced this pull request Mar 31, 2026
Take first task group for further execution
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 31, 2026
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Mar 31, 2026

☀️ Try build successful (CI)
Build commit: 7162208 (7162208e3ee809a53abb3682431abfd4dd7bf537, parent: cf7da0b7277cad05b79f91b60c290aa08a17a6f0)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (7162208): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.4% [-0.6%, -0.1%] 2
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary 2.4%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.4% [1.6%, 3.1%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.4% [1.6%, 3.1%] 2

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 483.836s -> 484.409s (0.12%)
Artifact size: 394.90 MiB -> 394.83 MiB (-0.02%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 31, 2026
@nnethercote
Copy link
Copy Markdown
Contributor

@bors r+ rollup=maybe

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Mar 31, 2026

📌 Commit 576a727 has been approved by nnethercote

It is now in the queue for this repository.

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 31, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Mar 31, 2026
…ethercote

Take first task group for further execution

Continuing from rust-lang#153768 (comment).

I thought that storing a first group of tasks for immediate execution instead of pushing and immediately poping it from rayon's local task queue in par_slice would avoid overwhelming work stealing potentially blocking the original thread. So I've implemented this change.

8 threads benchmarks:

<table><tr><td rowspan="2">Benchmark</td><td colspan="1"><b>baseline~~9</b></th><td colspan="2"><b>new~take-first-group~1</b></th></tr><tr><td align="right">Time</td><td align="right">Time</td><td align="right">%</th></tr><tr><td>🟣 <b>hyper</b>:check</td><td align="right">0.1110s</td><td align="right">0.1086s</td><td align="right">💚  -2.13%</td></tr><tr><td>🟣 <b>hyper</b>:check:initial</td><td align="right">0.1314s</td><td align="right">0.1298s</td><td align="right">💚  -1.23%</td></tr><tr><td>🟣 <b>hyper</b>:check:unchanged</td><td align="right">0.0771s</td><td align="right">0.0755s</td><td align="right">💚  -2.14%</td></tr><tr><td>🟣 <b>clap</b>:check</td><td align="right">0.3787s</td><td align="right">0.3757s</td><td align="right"> -0.80%</td></tr><tr><td>🟣 <b>clap</b>:check:initial</td><td align="right">0.4680s</td><td align="right">0.4564s</td><td align="right">💚  -2.48%</td></tr><tr><td>🟣 <b>clap</b>:check:unchanged</td><td align="right">0.2337s</td><td align="right">0.2301s</td><td align="right">💚  -1.52%</td></tr><tr><td>🟣 <b>syn</b>:check</td><td align="right">0.4321s</td><td align="right">0.4265s</td><td align="right">💚  -1.31%</td></tr><tr><td>🟣 <b>syn</b>:check:initial</td><td align="right">0.5586s</td><td align="right">0.5401s</td><td align="right">💚  -3.31%</td></tr><tr><td>🟣 <b>syn</b>:check:unchanged</td><td align="right">0.3434s</td><td align="right">0.3429s</td><td align="right"> -0.14%</td></tr><tr><td>🟣 <b>regex</b>:check</td><td align="right">0.2755s</td><td align="right">0.2661s</td><td align="right">💚  -3.40%</td></tr><tr><td>🟣 <b>regex</b>:check:initial</td><td align="right">0.3350s</td><td align="right">0.3347s</td><td align="right"> -0.11%</td></tr><tr><td>🟣 <b>regex</b>:check:unchanged</td><td align="right">0.1851s</td><td align="right">0.1832s</td><td align="right">💚  -1.01%</td></tr><tr><td>Total</td><td align="right">3.5296s</td><td align="right">3.4695s</td><td align="right">💚  -1.70%</td></tr><tr><td>Summary</td><td align="right">1.0000s</td><td align="right">0.9837s</td><td align="right">💚  -1.63%</td></tr></table>
rust-bors bot pushed a commit that referenced this pull request Mar 31, 2026
…uwer

Rollup of 12 pull requests

Successful merges:

 - #154419 (Take first task group for further execution)
 - #154569 (Fix  type alias where clause suggestion spacing issue)
 - #154617 (Update flate2 users to use zlib-rs)
 - #154618 (Fix AtomicPtr::update's cfg gate)
 - #154620 (stabilize new Range type and iterator)
 - #151932 (refactor: remove `Adjust::ReborrowPin`)
 - #153980 (refactor: move doc(rust_logo) check to parser)
 - #154134 (fix: guard paren-sugar pretty-printing on short trait args)
 - #154270 (Create `Ty` type alias in `rustc_type_ir`)
 - #154580 (Split AttributeParserError Diagnostic implementation into subfunctions)
 - #154606 (misc test cleanups)
 - #154612 (Add a test for a now fixed ICE with `offset_of!()`)
@rust-bors rust-bors bot merged commit 8427445 into rust-lang:main Mar 31, 2026
12 checks passed
@rustbot rustbot added this to the 1.96.0 milestone Mar 31, 2026
rust-timer added a commit that referenced this pull request Mar 31, 2026
Rollup merge of #154419 - zetanumbers:take-first-group, r=nnethercote

Take first task group for further execution

Continuing from #153768 (comment).

I thought that storing a first group of tasks for immediate execution instead of pushing and immediately poping it from rayon's local task queue in par_slice would avoid overwhelming work stealing potentially blocking the original thread. So I've implemented this change.

8 threads benchmarks:

<table><tr><td rowspan="2">Benchmark</td><td colspan="1"><b>baseline~~9</b></th><td colspan="2"><b>new~take-first-group~1</b></th></tr><tr><td align="right">Time</td><td align="right">Time</td><td align="right">%</th></tr><tr><td>🟣 <b>hyper</b>:check</td><td align="right">0.1110s</td><td align="right">0.1086s</td><td align="right">💚  -2.13%</td></tr><tr><td>🟣 <b>hyper</b>:check:initial</td><td align="right">0.1314s</td><td align="right">0.1298s</td><td align="right">💚  -1.23%</td></tr><tr><td>🟣 <b>hyper</b>:check:unchanged</td><td align="right">0.0771s</td><td align="right">0.0755s</td><td align="right">💚  -2.14%</td></tr><tr><td>🟣 <b>clap</b>:check</td><td align="right">0.3787s</td><td align="right">0.3757s</td><td align="right"> -0.80%</td></tr><tr><td>🟣 <b>clap</b>:check:initial</td><td align="right">0.4680s</td><td align="right">0.4564s</td><td align="right">💚  -2.48%</td></tr><tr><td>🟣 <b>clap</b>:check:unchanged</td><td align="right">0.2337s</td><td align="right">0.2301s</td><td align="right">💚  -1.52%</td></tr><tr><td>🟣 <b>syn</b>:check</td><td align="right">0.4321s</td><td align="right">0.4265s</td><td align="right">💚  -1.31%</td></tr><tr><td>🟣 <b>syn</b>:check:initial</td><td align="right">0.5586s</td><td align="right">0.5401s</td><td align="right">💚  -3.31%</td></tr><tr><td>🟣 <b>syn</b>:check:unchanged</td><td align="right">0.3434s</td><td align="right">0.3429s</td><td align="right"> -0.14%</td></tr><tr><td>🟣 <b>regex</b>:check</td><td align="right">0.2755s</td><td align="right">0.2661s</td><td align="right">💚  -3.40%</td></tr><tr><td>🟣 <b>regex</b>:check:initial</td><td align="right">0.3350s</td><td align="right">0.3347s</td><td align="right"> -0.11%</td></tr><tr><td>🟣 <b>regex</b>:check:unchanged</td><td align="right">0.1851s</td><td align="right">0.1832s</td><td align="right">💚  -1.01%</td></tr><tr><td>Total</td><td align="right">3.5296s</td><td align="right">3.4695s</td><td align="right">💚  -1.70%</td></tr><tr><td>Summary</td><td align="right">1.0000s</td><td align="right">0.9837s</td><td align="right">💚  -1.63%</td></tr></table>
github-actions bot pushed a commit to rust-lang/compiler-builtins that referenced this pull request Mar 31, 2026
…uwer

Rollup of 12 pull requests

Successful merges:

 - rust-lang/rust#154419 (Take first task group for further execution)
 - rust-lang/rust#154569 (Fix  type alias where clause suggestion spacing issue)
 - rust-lang/rust#154617 (Update flate2 users to use zlib-rs)
 - rust-lang/rust#154618 (Fix AtomicPtr::update's cfg gate)
 - rust-lang/rust#154620 (stabilize new Range type and iterator)
 - rust-lang/rust#151932 (refactor: remove `Adjust::ReborrowPin`)
 - rust-lang/rust#153980 (refactor: move doc(rust_logo) check to parser)
 - rust-lang/rust#154134 (fix: guard paren-sugar pretty-printing on short trait args)
 - rust-lang/rust#154270 (Create `Ty` type alias in `rustc_type_ir`)
 - rust-lang/rust#154580 (Split AttributeParserError Diagnostic implementation into subfunctions)
 - rust-lang/rust#154606 (misc test cleanups)
 - rust-lang/rust#154612 (Add a test for a now fixed ICE with `offset_of!()`)
RalfJung pushed a commit to RalfJung/miri that referenced this pull request Apr 1, 2026
…uwer

Rollup of 12 pull requests

Successful merges:

 - rust-lang/rust#154419 (Take first task group for further execution)
 - rust-lang/rust#154569 (Fix  type alias where clause suggestion spacing issue)
 - rust-lang/rust#154617 (Update flate2 users to use zlib-rs)
 - rust-lang/rust#154618 (Fix AtomicPtr::update's cfg gate)
 - rust-lang/rust#154620 (stabilize new Range type and iterator)
 - rust-lang/rust#151932 (refactor: remove `Adjust::ReborrowPin`)
 - rust-lang/rust#153980 (refactor: move doc(rust_logo) check to parser)
 - rust-lang/rust#154134 (fix: guard paren-sugar pretty-printing on short trait args)
 - rust-lang/rust#154270 (Create `Ty` type alias in `rustc_type_ir`)
 - rust-lang/rust#154580 (Split AttributeParserError Diagnostic implementation into subfunctions)
 - rust-lang/rust#154606 (misc test cleanups)
 - rust-lang/rust#154612 (Add a test for a now fixed ICE with `offset_of!()`)
github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Apr 6, 2026
…uwer

Rollup of 12 pull requests

Successful merges:

 - rust-lang/rust#154419 (Take first task group for further execution)
 - rust-lang/rust#154569 (Fix  type alias where clause suggestion spacing issue)
 - rust-lang/rust#154617 (Update flate2 users to use zlib-rs)
 - rust-lang/rust#154618 (Fix AtomicPtr::update's cfg gate)
 - rust-lang/rust#154620 (stabilize new Range type and iterator)
 - rust-lang/rust#151932 (refactor: remove `Adjust::ReborrowPin`)
 - rust-lang/rust#153980 (refactor: move doc(rust_logo) check to parser)
 - rust-lang/rust#154134 (fix: guard paren-sugar pretty-printing on short trait args)
 - rust-lang/rust#154270 (Create `Ty` type alias in `rustc_type_ir`)
 - rust-lang/rust#154580 (Split AttributeParserError Diagnostic implementation into subfunctions)
 - rust-lang/rust#154606 (misc test cleanups)
 - rust-lang/rust#154612 (Add a test for a now fixed ICE with `offset_of!()`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants