-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Scheduler multithreading #6839
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
Scheduler multithreading #6839
Conversation
This is used for signalling the event loop from other threads.
This will be for implementing a work-sharing strategy
Just a simple place to stuff handles to sleeping schedulers.
…infinite recursion
Conflicts: src/libstd/rt/sched.rs
This properly distributes the load now
/me reads |
I made a branch where I inserted comments and made some minor changes: https://github.com/nikomatsakis/rust/tree/brson-io-upstream This commit in particular: @brson maybe we can chat with vidyo on Monday to clear up some of the things I am confused about? |
By the way the code is pretty nice! I'd like to see a file |
@nikomatsakis sure we can talk about it monday. I also threw in some new commits that implement SharedChan and SharedPort. When combined they amount to an unbounded, multiple producer/multiple consumer queue. |
Removed SharedChan/Port commits because they are buggy. |
I've cleaned this up so it only contains the parts that I believe are pretty stable. I intend to go apply some of feedback in your commit still, but may not write the docs for a while. |
Also, still waiting for incoming to be green. I've got that bug in my sights, though. |
r+. I didn't add tihs to the commit since it's not mergeable. plus, I didn't expect you to write the docs yet :) |
…, r=flip1995 lintcheck: fix clippy warnings split out from rust-lang/rust-clippy#6829 changelog: none
r? @nikomatsakis
This implements very basic multithreading in the new scheduler. This is only using a trivial scheduling strategy with a shared task queue. It adds three new concurrent types to the scheduler:
WorkQueue
,MessageQueue
, andSleeperList
.WorkQueue
is temporarily just a basic queue;MessageQueue
is a multiple-producer, singe-consumer queue for sending messages to schedulers; andSleeperList
is a shared stack used for waking up sleeping schedulers. All three are intended to be lock free but for now are implemented naively with locks.The main scheduling routine, which uses all three of these data structures is here: https://github.com/brson/rust/blob/io-upstream/src/libstd/rt/sched.rs#L156
An example of how the multithreaded scheduler is constructed: https://github.com/brson/rust/blob/io-upstream/src/libstd/rt/test.rs#L62
#4419