Skip to content

Use scope for par_slice instead of join#152375

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
Zoxc:rayon-scope-loops
Feb 15, 2026
Merged

Use scope for par_slice instead of join#152375
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
Zoxc:rayon-scope-loops

Conversation

@Zoxc
Copy link
Contributor

@Zoxc Zoxc commented Feb 9, 2026

This uses scope instead of nested joins in par_slice so that each group of items are independent and do not end up blocking on another.

@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 Feb 9, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 9, 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 21 candidates
  • Random selection from 12 candidates

@Zoxc
Copy link
Contributor Author

Zoxc commented Feb 9, 2026

2 threads:

BenchmarkBeforeAfterBeforeAfterBeforeAfter
TimeTime%Physical MemoryPhysical Memory%Committed MemoryCommitted Memory%
🟣 clap:check0.8287s0.6686s💚 -19.31%196.68 MiB196.74 MiB 0.03%259.40 MiB259.65 MiB 0.10%
🟣 hyper:check0.1818s0.1755s💚 -3.45%124.01 MiB123.98 MiB -0.03%192.48 MiB192.27 MiB -0.11%
🟣 regex:check0.5007s0.4895s💚 -2.23%161.53 MiB161.91 MiB 0.23%222.77 MiB223.70 MiB 0.42%
🟣 syn:check0.9904s0.8646s💚 -12.70%190.95 MiB191.51 MiB 0.29%250.10 MiB250.62 MiB 0.21%
Total2.5015s2.1982s💚 -12.12%673.17 MiB674.14 MiB 0.14%924.76 MiB926.25 MiB 0.16%
Summary1.0000s0.9058s💚 -9.42%1 byte1.00 bytes 0.13%1 byte1.00 bytes 0.15%

4 threads:

BenchmarkBeforeAfterBeforeAfterBeforeAfter
TimeTime%Physical MemoryPhysical Memory%Committed MemoryCommitted Memory%
🟣 clap:check0.5300s0.4627s💚 -12.70%201.49 MiB200.95 MiB -0.27%266.75 MiB264.40 MiB -0.88%
🟣 hyper:check0.1467s0.1386s💚 -5.48%125.32 MiB125.45 MiB 0.11%193.67 MiB193.92 MiB 0.13%
🟣 regex:check0.3727s0.3456s💚 -7.29%163.81 MiB163.99 MiB 0.11%224.09 MiB225.49 MiB 0.62%
🟣 syn:check0.7220s0.6361s💚 -11.90%194.21 MiB194.35 MiB 0.07%255.50 MiB254.83 MiB -0.26%
Total1.7714s1.5830s💚 -10.64%684.83 MiB684.74 MiB -0.01%940.00 MiB938.64 MiB -0.14%
Summary1.0000s0.9066s💚 -9.34%1 byte1.00 bytes 0.01%1 byte1.00 bytes -0.10%

8 threads:

BenchmarkBeforeAfterBeforeAfterBeforeAfter
TimeTime%Physical MemoryPhysical Memory%Committed MemoryCommitted Memory%
🟣 clap:check0.3941s0.3575s💚 -9.30%204.98 MiB205.60 MiB 0.30%274.74 MiB272.39 MiB -0.85%
🟣 hyper:check0.1251s0.1223s💚 -2.21%127.23 MiB127.37 MiB 0.11%195.76 MiB195.83 MiB 0.04%
🟣 regex:check0.2753s0.2606s💚 -5.35%167.11 MiB167.35 MiB 0.15%228.08 MiB228.38 MiB 0.13%
🟣 syn:check0.5390s0.5030s💚 -6.68%197.82 MiB198.34 MiB 0.26%259.46 MiB258.20 MiB -0.49%
Total1.3336s1.2434s💚 -6.76%697.14 MiB698.67 MiB 0.22%958.03 MiB954.80 MiB -0.34%
Summary1.0000s0.9411s💚 -5.89%1 byte1.00 bytes 0.21%1 byte1.00 bytes -0.29%

@lqd
Copy link
Member

lqd commented Feb 9, 2026

Sanity check on single-threaded execution:

@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 Feb 9, 2026
Use `scope` for `par_slice` instead of `join`
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 9, 2026
Copy link
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

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

Nice, thanks
@bors r+ rollup=never

View changes since this review

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 9, 2026

📌 Commit 91a6126 has been approved by jieyouxu

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 Feb 9, 2026
@jieyouxu
Copy link
Member

jieyouxu commented Feb 9, 2026

(Since we're doing a check, r=me if it comes back sane :D)
@bors r-

@rust-bors rust-bors bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 9, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 9, 2026

☀️ Try build successful (CI)
Build commit: 5c74e7e (5c74e7e145c69332c280c8f328843bb9a3017c59, parent: c6936c309add33a7008747866aee081ff5289946)

@rust-timer

This comment has been minimized.

@lqd
Copy link
Member

lqd commented Feb 10, 2026

The bot didn't want to tell us the results, but they're ready: neutral on icounts, but wall-time improves on the only -threads4 benchmark.

@bors r=jieyouxu,lqd

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 10, 2026

📌 Commit 91a6126 has been approved by jieyouxu,lqd

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 10, 2026
@rust-bors

This comment has been minimized.

@rust-bors rust-bors bot added the merged-by-bors This PR was explicitly merged by bors. label Feb 15, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 15, 2026

☀️ Test successful - CI
Approved by: jieyouxu,lqd
Duration: 3h 42m 20s
Pushing 4c37f6d to main...

@rust-bors rust-bors bot removed the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Feb 15, 2026
@rust-bors rust-bors bot merged commit 4c37f6d into rust-lang:main Feb 15, 2026
13 checks passed
@rustbot rustbot added this to the 1.95.0 milestone Feb 15, 2026
@github-actions
Copy link
Contributor

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing ce0bf0b (parent) -> 4c37f6d (this PR)

Test differences

Show 2 test diffs

2 doctest diffs were found. These are ignored, as they are noisy.

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 4c37f6d78c9c83e05caa0d1e43ce7d0c3f27538e --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. dist-aarch64-apple: 1h 46m -> 2h 26m (+38.3%)
  2. dist-apple-various: 3h 12m -> 2h 2m (-36.2%)
  3. dist-x86_64-apple: 2h 5m -> 2h 49m (+35.8%)
  4. dist-aarch64-linux: 2h 34m -> 1h 44m (-32.4%)
  5. x86_64-msvc-ext3: 1h 41m -> 1h 54m (+12.4%)
  6. x86_64-gnu-llvm-21-3: 1h 44m -> 1h 56m (+11.9%)
  7. x86_64-gnu-llvm-20-2: 1h 31m -> 1h 41m (+11.0%)
  8. dist-aarch64-llvm-mingw: 1h 55m -> 1h 44m (-9.7%)
  9. tidy: 3m 3s -> 2m 46s (-9.2%)
  10. x86_64-gnu-aux: 2h 20m -> 2h 8m (-8.7%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@Zoxc Zoxc deleted the rayon-scope-loops branch February 15, 2026 14:03
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (4c37f6d): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

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

Max RSS (memory usage)

Results (primary 3.5%, secondary 7.2%)

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

mean range count
Regressions ❌
(primary)
3.5% [3.5%, 3.5%] 1
Regressions ❌
(secondary)
7.2% [7.2%, 7.2%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 3.5% [3.5%, 3.5%] 1

Cycles

Results (secondary 2.4%)

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

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.4% [1.9%, 3.0%] 4
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

Results (primary -0.0%, secondary -0.1%)

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

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.0% [-0.1%, -0.0%] 16
Improvements ✅
(secondary)
-0.1% [-0.1%, -0.0%] 16
All ❌✅ (primary) -0.0% [-0.1%, -0.0%] 16

Bootstrap: 479.824s -> 480.702s (0.18%)
Artifact size: 397.98 MiB -> 397.88 MiB (-0.03%)

@petrochenkov
Copy link
Contributor

This change broke parallel frontend pretty severely, perhaps by unearthing some pre-existing issues perhaps not.
Now compilation of libstd never succeeds for me with -Zthreads=8, producing linking errors due to missing symbols.

Zulip discussion: #t-compiler/parallel-rustc > Steps to enable/stabilize multi-threaded rustc front-end @ 💬.

rustc_thread_pool::scope(|s| {
let proof = items.derive(());
let group_size = std::cmp::max(items.len() / 128, 1);
for group in items.chunks_exact_mut(group_size) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Hold on. chunks_exact_mut and not chunks_mut?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, looks like some items are simply not processed now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, that would skew performance numbers too.

@zetanumbers
Copy link
Contributor

Benchmark results above aren't real as this PR basically disables some code from running because of chunks_exact_mut.

@Zoxc
Copy link
Contributor Author

Zoxc commented Feb 16, 2026

Updated benchmarks with chunks_exact_mut swapped with chunks_mut:

2 threads:

BenchmarkBeforeAfterBeforeAfterBeforeAfter
TimeTime%Physical MemoryPhysical Memory%Committed MemoryCommitted Memory%
🟣 clap:check0.8032s0.6532s💚 -18.67%197.15 MiB197.41 MiB 0.13%260.51 MiB260.72 MiB 0.08%
🟣 hyper:check0.1638s0.1582s💚 -3.44%124.29 MiB124.17 MiB -0.10%193.24 MiB192.94 MiB -0.16%
🟣 regex:check0.4088s0.3968s💚 -2.92%161.80 MiB162.15 MiB 0.22%223.60 MiB224.33 MiB 0.32%
🟣 syn:check0.9406s0.8248s💚 -12.31%191.71 MiB191.69 MiB -0.01%250.91 MiB250.92 MiB 0.00%
Total2.3164s2.0331s💚 -12.23%674.96 MiB675.41 MiB 0.07%928.26 MiB928.90 MiB 0.07%
Summary1.0000s0.9066s💚 -9.34%1 byte1.00 bytes 0.06%1 byte1.00 bytes 0.06%

4 threads:

BenchmarkBeforeAfterBeforeAfterBeforeAfter
TimeTime%Physical MemoryPhysical Memory%Committed MemoryCommitted Memory%
🟣 clap:check0.5252s0.4536s💚 -13.64%201.81 MiB201.52 MiB -0.14%267.17 MiB264.95 MiB -0.83%
🟣 hyper:check0.1415s0.1324s💚 -6.47%125.68 MiB125.67 MiB -0.01%194.50 MiB194.71 MiB 0.11%
🟣 regex:check0.3127s0.2878s💚 -7.95%164.96 MiB164.94 MiB -0.01%225.97 MiB226.76 MiB 0.35%
🟣 syn:check0.6196s0.5462s💚 -11.85%194.97 MiB195.18 MiB 0.11%256.20 MiB256.00 MiB -0.08%
Total1.5991s1.4200s💚 -11.20%687.41 MiB687.31 MiB -0.02%943.84 MiB942.42 MiB -0.15%
Summary1.0000s0.9002s💚 -9.98%1 byte1.00 bytes -0.01%1 byte1.00 bytes -0.11%

8 threads:

BenchmarkBeforeAfterBeforeAfterBeforeAfter
TimeTime%Physical MemoryPhysical Memory%Committed MemoryCommitted Memory%
🟣 clap:check0.3908s0.3538s💚 -9.48%205.43 MiB206.26 MiB 0.41%275.05 MiB273.23 MiB -0.66%
🟣 hyper:check0.1237s0.1210s💚 -2.19%127.57 MiB127.75 MiB 0.14%196.57 MiB196.71 MiB 0.07%
🟣 regex:check0.2475s0.2346s💚 -5.18%167.78 MiB168.32 MiB 0.32%229.00 MiB229.69 MiB 0.30%
🟣 syn:check0.4590s0.4222s💚 -8.02%198.82 MiB198.89 MiB 0.03%260.29 MiB259.00 MiB -0.50%
Total1.2210s1.1316s💚 -7.32%699.59 MiB701.22 MiB 0.23%960.92 MiB958.63 MiB -0.24%
Summary1.0000s0.9378s💚 -6.22%1 byte1.00 bytes 0.23%1 byte1.00 bytes -0.20%

@zetanumbers
Copy link
Contributor

zetanumbers commented Feb 16, 2026

Hmm, such large variance doesn't look good. Rcb benchmarks are very unreliable for multiple threads. Although all greens and above 5% stats gives me a reason to believe this is not a fluke.

rust-bors bot pushed a commit that referenced this pull request Feb 17, 2026
…rochenkov,jieyouxu

Fix wrong par_slice implementation

#152375 (comment)
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Feb 18, 2026
github-actions bot pushed a commit to rust-lang/rust-analyzer that referenced this pull request Feb 23, 2026
github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Feb 23, 2026
rust-bors bot pushed a commit that referenced this pull request Mar 21, 2026
…,Zoxc

Make `par_slice` consistent with single-threaded execution



#152375 removed this consistency by switching from order preserving join to scope, which does not preserve order as stated in `par_fns` as well. This also makes `par_slice` behavior consistent with `par_fns`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-by-bors This PR was explicitly merged by bors. S-waiting-on-perf Status: Waiting on a perf run to be completed. 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