-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Simplify parallel! macro #152329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Simplify parallel! macro #152329
Conversation
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Simplify parallel! macro
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (00e0ea3): comparison URL. Overall result: no relevant changes - no action neededBenchmarking 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 Instruction countThis 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.
CyclesResults (secondary -3.3%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 471.737s -> 472.587s (0.18%) |
4926482 to
95495be
Compare
|
r? @jackh726 rustbot has assigned @jackh726. Use Why was this reviewer chosen?The reviewer was selected based on:
|
There was a problem hiding this 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.
| return; | ||
| }; | ||
|
|
||
| // Reverse the order of the later closures since Rayon executes them in reverse order |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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]()); |
There was a problem hiding this comment.
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)]) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
| /// 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)]) { |
There was a problem hiding this comment.
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".
a6727dd to
8c5ce26
Compare
|
Good change, thanks. |
|
@bors r+ rollup |
…hercote Simplify parallel! macro This replaces the `parallel!` macro with a `par_fns` function.
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)
…hercote Simplify parallel! macro This replaces the `parallel!` macro with a `par_fns` function.
This replaces the
parallel!macro with apar_fnsfunction.