Skip to content

Commit d5e18e3

Browse files
bors[bot]cuviper
andauthored
Merge #997
997: Guard `par_bridge` against work-stealing recursion r=cuviper a=cuviper It doesn't make sense for the `par_bridge` producer to run nested on one thread, since each split is capable of running the entire iterator to completion. However, this can still happen if the serial iterator or the consumer side make any rayon calls that would block, where it may go into work-stealing and start another split of the `par_bridge`. With the iterator in particular, this is a problem because we'll already be holding the mutex, so trying to lock again will deadlock or panic. We now set a flag in each thread when they start working on the bridge, and bail out if we re-enter that bridge again on the same thread. The new `par_bridge_recursion` test would previously hang almost every time for me, but runs reliably with this new check in place. Co-authored-by: Josh Stone <[email protected]>
2 parents 78feb98 + 2d177d9 commit d5e18e3

File tree

5 files changed

+166
-93
lines changed

5 files changed

+166
-93
lines changed

Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rayon"
3-
version = "1.6.0"
3+
version = "1.6.1"
44
authors = ["Niko Matsakis <[email protected]>",
55
"Josh Stone <[email protected]>"]
66
description = "Simple work-stealing parallelism for Rust"
@@ -20,7 +20,6 @@ exclude = ["ci"]
2020

2121
[dependencies]
2222
rayon-core = { version = "1.10.0", path = "rayon-core" }
23-
crossbeam-deque = "0.8.1"
2423

2524
# This is a public dependency!
2625
[dependencies.either]

RELEASES.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# Release rayon 1.6.1 (2022-12-09)
2+
3+
- Simplified `par_bridge` to only pull one item at a time from the iterator,
4+
without batching. Threads that are waiting for iterator items will now block
5+
appropriately rather than spinning CPU. (Thanks @njaard!)
6+
- Added protection against recursion in `par_bridge`, so iterators that also
7+
invoke rayon will not cause mutex recursion deadlocks.
8+
19
# Release rayon-core 1.10.1 (2022-11-18)
210

311
- Fixed a race condition with threads going to sleep while a broadcast starts.

0 commit comments

Comments
 (0)