Skip to content
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

new scheduler from RFC 5 #746

Merged
merged 33 commits into from Aug 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
5d5301b
adjust sleep module API to have an `IdleState` object
nikomatsakis Nov 2, 2019
bb59970
port to the new log api
nikomatsakis Nov 2, 2019
2442f67
remove JobPoppedRhs event and register JobPopped from take_local_job
nikomatsakis Nov 3, 2019
2458fee
remove pure "debug" events; this lowers overhead of enabling logging
nikomatsakis Nov 3, 2019
cddc265
add --skip-bridge option to life
nikomatsakis Jan 18, 2020
2803c59
add new thread-pool
nikomatsakis Jan 18, 2020
0b31522
document the new logging infrastructure more accurately
nikomatsakis Apr 7, 2020
0713753
Read all SpinLatch fields before we call set()
cuviper Mar 11, 2020
cbd484c
Keep the registry alive for a cross-pool SpinLatch
cuviper Mar 11, 2020
90da62d
apply cargo fmt
nikomatsakis Apr 7, 2020
30f5928
add missing lifetime annotation
nikomatsakis Aug 4, 2020
b8017a3
update to crossbeam-channel 0.4
cuviper Apr 8, 2020
e2fc62e
Update rayon-core/src/registry.rs
nikomatsakis Apr 10, 2020
c554e94
add warning comments
nikomatsakis Apr 10, 2020
0253df0
add some comments explaining what is going on in a bit more depth.
nikomatsakis Apr 10, 2020
4619d34
[WIP] start adding comments
nikomatsakis Apr 10, 2020
d511364
adopt the "ignore rollect, even-odd JEC" design
nikomatsakis Apr 11, 2020
e460cc4
use usize instead of u16
nikomatsakis Apr 11, 2020
8a99d66
rename JOBS to JEC, comment constants
nikomatsakis Apr 11, 2020
2c22c80
rename from INVALID to MAX
nikomatsakis Apr 11, 2020
908e137
WIP: rework to permit rollover at arbitrary points
nikomatsakis Apr 11, 2020
1222cbe
check one last time for injected jobs before sleep
nikomatsakis Apr 13, 2020
2124e83
rename "raw idle" to "inactive"
nikomatsakis Apr 13, 2020
5d89960
begin updating README
nikomatsakis Apr 14, 2020
d59dcd6
simplified JEC scheme
nikomatsakis Apr 15, 2020
490a39f
prep work for usize JEC
nikomatsakis Apr 15, 2020
71d214e
change to AtomicUsize
nikomatsakis Apr 15, 2020
700061b
document bit layout correctly
nikomatsakis Apr 15, 2020
76ce5f5
Add #[inline] to tiny counter/latch methods
cuviper May 6, 2020
a0efb4a
transition to even/odd scheme
nikomatsakis May 13, 2020
c3a5304
Correct the bit test in JobsEventCounter::is_sleepy
cuviper May 15, 2020
96ba9ef
inline more Counter methods
cuviper May 15, 2020
ed6a5f7
Update ci/compat-Cargo.lock
cuviper Aug 13, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
307 changes: 159 additions & 148 deletions ci/compat-Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions rayon-core/Cargo.toml
Expand Up @@ -18,6 +18,7 @@ categories = ["concurrency"]
[dependencies]
num_cpus = "1.2"
lazy_static = "1"
crossbeam-channel = "0.4.2"
Copy link
Member

Choose a reason for hiding this comment

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

It's slightly disappointing to add a dependency just for usually-disabled logging, but I guess it doesn't add much since we're already invested in crossbeam. I also see that we can't just use std::sync::mpsc for that as it's !Sync.

Copy link
Member Author

Choose a reason for hiding this comment

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

My original intention was to collect the events in per-thread queues and then fire them off somewhere central only every once in a while, but I decided to "just try" crossbeam-channel and see how it performs. It turned out to perform pretty well and logging had no observable impact on performance. Later I found that in some use cases it performed less well and does have an observable impact. Maybe I should swap this out for Mutex<Channel> and we can revisit later?

Choose a reason for hiding this comment

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

@nikomatsakis The tracing crate might help here.

crossbeam-deque = "0.7.2"
crossbeam-queue = "0.2"
crossbeam-utils = "0.7"
Expand Down
20 changes: 3 additions & 17 deletions rayon-core/src/join/mod.rs
@@ -1,6 +1,5 @@
use crate::job::StackJob;
use crate::latch::{LatchProbe, SpinLatch};
use crate::log::Event::*;
use crate::latch::SpinLatch;
use crate::registry::{self, WorkerThread};
use crate::unwind;
use std::any::Any;
Expand Down Expand Up @@ -131,14 +130,10 @@ where
}

registry::in_worker(|worker_thread, injected| unsafe {
log!(Join {
worker: worker_thread.index()
});

// Create virtual wrapper for task b; this all has to be
// done here so that the stack frame can keep it all live
// long enough.
let job_b = StackJob::new(call_b(oper_b), SpinLatch::new());
let job_b = StackJob::new(call_b(oper_b), SpinLatch::new(worker_thread));
let job_b_ref = job_b.as_job_ref();
worker_thread.push(job_b_ref);

Expand All @@ -160,23 +155,14 @@ where
// Found it! Let's run it.
//
// Note that this could panic, but it's ok if we unwind here.
log!(PoppedRhs {
worker: worker_thread.index()
});
let result_b = job_b.run_inline(injected);
return (result_a, result_b);
} else {
log!(PoppedJob {
worker: worker_thread.index()
});
worker_thread.execute(job);
}
} else {
// Local deque is empty. Time to steal from other
// threads.
log!(LostJob {
worker: worker_thread.index()
});
worker_thread.wait_until(&job_b.latch);
debug_assert!(job_b.latch.probe());
break;
Expand All @@ -193,7 +179,7 @@ where
#[cold] // cold path
unsafe fn join_recover_from_panic(
worker_thread: &WorkerThread,
job_b_latch: &SpinLatch,
job_b_latch: &SpinLatch<'_>,
err: Box<dyn Any + Send>,
) -> ! {
worker_thread.wait_until(job_b_latch);
Expand Down