diff options
| author | bors <bors@rust-lang.org> | 2013-08-08 16:32:02 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-08-08 16:32:02 -0700 |
| commit | 936f70bd878327d867b6f8f82061d738355a47c9 (patch) | |
| tree | 99590d1ce91866f282407ecf5c3ace367678b20e /src/libstd/task | |
| parent | 8f65dbfcfa11aa521aa59881f6ab064bbd07184e (diff) | |
| parent | af2e03998d4d06f2781ca72ec005f6913148f8bb (diff) | |
| download | rust-936f70bd878327d867b6f8f82061d738355a47c9.tar.gz rust-936f70bd878327d867b6f8f82061d738355a47c9.zip | |
auto merge of #8356 : toddaaro/rust/ws, r=brson
This pull request converts the scheduler from a naive shared queue scheduler to a naive workstealing scheduler. The deque is still a queue inside a lock, but there is still a substantial performance gain. Fiddling with the messaging benchmark I got a ~10x speedup and observed massively reduced memory usage. There are still *many* locations for optimization, but based on my experience so far it is a clear performance win as it is now.
Diffstat (limited to 'src/libstd/task')
| -rw-r--r-- | src/libstd/task/spawn.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/libstd/task/spawn.rs b/src/libstd/task/spawn.rs index 2d0a2d98e9f..05a17f8539c 100644 --- a/src/libstd/task/spawn.rs +++ b/src/libstd/task/spawn.rs @@ -98,6 +98,7 @@ use rt::kill::KillHandle; use rt::sched::Scheduler; use rt::uv::uvio::UvEventLoop; use rt::thread::Thread; +use rt::work_queue::WorkQueue; #[cfg(test)] use task::default_task_opts; #[cfg(test)] use comm; @@ -722,10 +723,16 @@ fn spawn_raw_newsched(mut opts: TaskOpts, f: ~fn()) { let sched = Local::unsafe_borrow::<Scheduler>(); let sched_handle = (*sched).make_handle(); + // Since this is a 1:1 scheduler we create a queue not in + // the stealee set. The run_anything flag is set false + // which will disable stealing. + let work_queue = WorkQueue::new(); + // Create a new scheduler to hold the new task let new_loop = ~UvEventLoop::new(); let mut new_sched = ~Scheduler::new_special(new_loop, - (*sched).work_queue.clone(), + work_queue, + (*sched).work_queues.clone(), (*sched).sleeper_list.clone(), false, Some(sched_handle)); |
