Skip to content

Commit 09428ec

Browse files
bors[bot]nikomatsakiscuviper
authored
Merge #746
746: new scheduler from RFC 5 r=cuviper a=nikomatsakis Implementation of the scheduler described in rayon-rs/rfcs#5 -- modulo the fact that the RFC is mildly out of date. There is a [walkthrough video available](https://youtu.be/HvmQsE5M4cY). To Do List: * [x] Fix the cargo lock * [x] Address use of `AtomicU64` * [x] Document the handling of rollover and wakeups and convince ourselves it's sound * [ ] Adopt and document the [proposed scheme for the job event counter](#746 (comment)) * [ ] Review RFC and list out the places where it differs from the branch Co-authored-by: Niko Matsakis <niko@alum.mit.edu> Co-authored-by: Josh Stone <cuviper@gmail.com>
2 parents 97b7e34 + ed6a5f7 commit 09428ec

11 files changed

Lines changed: 1713 additions & 1022 deletions

File tree

ci/compat-Cargo.lock

Lines changed: 159 additions & 148 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rayon-core/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ categories = ["concurrency"]
1818
[dependencies]
1919
num_cpus = "1.2"
2020
lazy_static = "1"
21+
crossbeam-channel = "0.4.2"
2122
crossbeam-deque = "0.7.2"
2223
crossbeam-queue = "0.2"
2324
crossbeam-utils = "0.7"

rayon-core/src/join/mod.rs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::job::StackJob;
2-
use crate::latch::{LatchProbe, SpinLatch};
3-
use crate::log::Event::*;
2+
use crate::latch::SpinLatch;
43
use crate::registry::{self, WorkerThread};
54
use crate::unwind;
65
use std::any::Any;
@@ -131,14 +130,10 @@ where
131130
}
132131

133132
registry::in_worker(|worker_thread, injected| unsafe {
134-
log!(Join {
135-
worker: worker_thread.index()
136-
});
137-
138133
// Create virtual wrapper for task b; this all has to be
139134
// done here so that the stack frame can keep it all live
140135
// long enough.
141-
let job_b = StackJob::new(call_b(oper_b), SpinLatch::new());
136+
let job_b = StackJob::new(call_b(oper_b), SpinLatch::new(worker_thread));
142137
let job_b_ref = job_b.as_job_ref();
143138
worker_thread.push(job_b_ref);
144139

@@ -160,23 +155,14 @@ where
160155
// Found it! Let's run it.
161156
//
162157
// Note that this could panic, but it's ok if we unwind here.
163-
log!(PoppedRhs {
164-
worker: worker_thread.index()
165-
});
166158
let result_b = job_b.run_inline(injected);
167159
return (result_a, result_b);
168160
} else {
169-
log!(PoppedJob {
170-
worker: worker_thread.index()
171-
});
172161
worker_thread.execute(job);
173162
}
174163
} else {
175164
// Local deque is empty. Time to steal from other
176165
// threads.
177-
log!(LostJob {
178-
worker: worker_thread.index()
179-
});
180166
worker_thread.wait_until(&job_b.latch);
181167
debug_assert!(job_b.latch.probe());
182168
break;
@@ -193,7 +179,7 @@ where
193179
#[cold] // cold path
194180
unsafe fn join_recover_from_panic(
195181
worker_thread: &WorkerThread,
196-
job_b_latch: &SpinLatch,
182+
job_b_latch: &SpinLatch<'_>,
197183
err: Box<dyn Any + Send>,
198184
) -> ! {
199185
worker_thread.wait_until(job_b_latch);

0 commit comments

Comments
 (0)