Skip to content

Take first task group for further execution#154419

Open
zetanumbers wants to merge 1 commit intorust-lang:mainfrom
zetanumbers:take-first-group
Open

Take first task group for further execution#154419
zetanumbers wants to merge 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%

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

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants