Skip to content

Conversation

@Zoxc
Copy link
Contributor

@Zoxc Zoxc commented Feb 8, 2026

This replaces the parallel! macro with a par_fns function.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 8, 2026
@Zoxc
Copy link
Contributor Author

Zoxc commented Feb 8, 2026

@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 8, 2026
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 8, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 8, 2026

☀️ Try build successful (CI)
Build commit: 00e0ea3 (00e0ea3c8c5e6aab513ed4e366a2cea0708cc658, parent: 13c38730d981289cc7ae4cc109fd7756bf83ee67)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (00e0ea3): comparison URL.

Overall result: no relevant changes - 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

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

Max RSS (memory usage)

Results (secondary -5.9%)

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
Improvements ✅
(secondary)
-5.9% [-5.9%, -5.9%] 1
All ❌✅ (primary) - - 0

Cycles

Results (secondary -3.3%)

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
Improvements ✅
(secondary)
-3.3% [-3.3%, -3.3%] 1
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 471.737s -> 472.587s (0.18%)
Artifact size: 397.92 MiB -> 397.90 MiB (-0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 8, 2026
@Zoxc Zoxc force-pushed the simple-parallel-macro branch from 4926482 to 95495be Compare February 9, 2026 01:54
@Zoxc Zoxc marked this pull request as ready for review February 9, 2026 02:12
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 9, 2026
@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Feb 9, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 9, 2026

r? @jackh726

rustbot has assigned @jackh726.
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

Copy link
Contributor

@nnethercote nnethercote left a comment

Choose a reason for hiding this comment

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

Nice change, the function form is much nicer to read than the macro. A few nits below.

View changes since this review

return;
};

// Reverse the order of the later closures since Rayon executes them in reverse order
Copy link
Contributor

Choose a reason for hiding this comment

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

"later" can be removed? The order here is just simple reversed, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm referring to rest and specifically excluding first, as first always runs first as we directly execute it.

});
}

guard.run(|| first[0]());
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably worth a brief comment about how/why the first function is run on the current thread, to avoid an unnecessary spawn.

///
/// The first block is executed immediately on the current thread.
/// Use that for the longest running block.
pub fn par_fns(funcs: &mut [&mut (dyn FnMut() + DynSend)]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it better to just keep the name parallel?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like the par prefix for fork-join functions. I changed it to par_blocks, that seems to match the current use better. I also renamed join to match.

@nnethercote nnethercote assigned nnethercote and unassigned jackh726 Feb 10, 2026
Copy link
Contributor

@nnethercote nnethercote left a comment

Choose a reason for hiding this comment

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

Getting closer. Can you also squash the two commits together? Thanks.

View changes since this review

/// Use that for the longest running block.
pub fn par_fns(funcs: &mut [&mut (dyn FnMut() + DynSend)]) {
/// Use that for the longest running block for better scheduling.
pub fn par_blocks(funcs: &mut [&mut (dyn FnMut() + DynSend)]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

par_blocks would have made sense with the macro implementation, because blocks are a macro concept. But it doesn't make sense here. par_fns is better. And the comments that refer to blocks should be changed to say "functions".

@Zoxc Zoxc force-pushed the simple-parallel-macro branch from a6727dd to 8c5ce26 Compare February 12, 2026 11:35
@nnethercote
Copy link
Contributor

Good change, thanks.

@nnethercote
Copy link
Contributor

@bors r+ rollup

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 12, 2026

📌 Commit 8c5ce26 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 Feb 12, 2026
Zalathar added a commit to Zalathar/rust that referenced this pull request Feb 13, 2026
…hercote

Simplify parallel! macro

This replaces the `parallel!` macro with a `par_fns` function.
rust-bors bot pushed a commit that referenced this pull request Feb 13, 2026
Rollup of 18 pull requests

Successful merges:

 - #150551 (Compute localized outlives constraints lazily)
 - #150752 (Update libc to v0.2.181)
 - #150988 (Improve code suggestion for incorrect macro_rules! usage)
 - #152422 (Change query proc macro to be more rust-analyzer friendly)
 - #152496 (Fix multi-cgu+debug builds using autodiff by delaying autodiff till lto)
 - #152514 (Collect active query jobs into struct `QueryJobMap`)
 - #152520 (Don't use `DepContext` in `rustc_middle::traits::cache`)
 - #152528 (Support serializing CodegenContext)
 - #152082 (Move tests)
 - #152232 (Add must_use for FileTimes)
 - #152329 (Simplify parallel! macro)
 - #152444 (`-Znext-solver` Prevent committing unfulfilled unsized coercion)
 - #152486 (remove redundant backchain attribute in codegen)
 - #152519 (Fix feature gating for new `try bikeshed` expressions)
 - #152529 (sparc64: enable abi compatibility test)
 - #152548 (reject inline const patterns pre-expansion)
 - #152550 (Port #[prelude_import] to the attribute parser)
 - #152552 (Add 2048-bit HvxVectorPair support to Hexagon SIMD ABI checks)
Zalathar added a commit to Zalathar/rust that referenced this pull request Feb 13, 2026
…hercote

Simplify parallel! macro

This replaces the `parallel!` macro with a `par_fns` function.
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.

6 participants