Skip to content
This repository has been archived by the owner on May 27, 2020. It is now read-only.

Implement work stealing in the Rust task scheduler #31

Closed
brson opened this issue Sep 24, 2012 · 12 comments
Closed

Implement work stealing in the Rust task scheduler #31

brson opened this issue Sep 24, 2012 · 12 comments

Comments

@brson
Copy link

brson commented Sep 24, 2012

The Rust task scheduler is quite primitive right now. One particular deficiency is that it does not ever migrate tasks between scheduler threads, resulting in threads often being under-utilized. We would like to resolve this using a 'work stealing' algorithm, where threads with no work ask other threads to give them tasks to run. This hacking is low-level, performance-critical and parallel.

See also: 3095, the cilk papers on work stealing

@vib67
Copy link

vib67 commented Dec 12, 2012

Hi
I am interested in this project can i take this up?

@brson
Copy link
Author

brson commented Dec 12, 2012

@vib67 yes!

@vib67
Copy link

vib67 commented Dec 12, 2012

Thanks. Will start working on it from tomorrow. I will ask for help if stuck anywhere.

@brson
Copy link
Author

brson commented Dec 12, 2012

Great! You may want to check in on IRC, #rust on irc.mozilla.org. There are a lot of people there that can help with general language issues.

@Yoric
Copy link
Contributor

Yoric commented Dec 13, 2012

Issue assigned to @vib67 .

@brson
Copy link
Author

brson commented Dec 13, 2012

@vib67 The Rust scheduler is one of the few parts of Rust written in C++, so most, if not all, the code for this project will be in C++, not Rust. Porting the scheduler to Rust is something we want to do in the future though.

Some entry points:

rust_task.h - The definition of a Rust task, which essentially consists of a linked list of stack segments, saved context, some heap bookkeeping, and quite a bit of synchronization code for various purposes.

rust_sched_loop.h - A single scheduler threaad, it executes the function run_single_turn repeatedly until told to exit.

Each loop maintains a list of tasks that it is responsible for. Tasks are scheduled by saving the current registers and loading the registers previously saved inside the task structure (a context switch). Tasks are deschudeled when the task calls yield() by doing a context switch back to the scheduler.

This project is about moving tasks between instances of rust_sched_loop.

rust_scheduler.h - The scheduler itself mostly just starts and stops rust_sched_loop.

libcore/task - The Rust interface to tasks and schedulers, including the public API, the internal task spawning code, and the declaration of the native interface

Once you've got your bearings I suggest outlining your plans on the relevant Rust bug ticket so that those interested might review the design.

@Yoric
Copy link
Contributor

Yoric commented Dec 13, 2012

By the way, @vib67 , just to keep track: which university are you from?

@vib67
Copy link

vib67 commented Dec 13, 2012

Hi, Thanks for sharing the information. I am from Aalto.

@vib67
Copy link

vib67 commented Dec 27, 2012

Hi I am getting the following problem during the compilation of rust code, Kindly help how to get or build /llvm-mc
/rust/code/rust/llvm/i686-unknown-linux-gnu/Release+Asserts/bin/llvm-mc: not found
make: *** [rt/i686-unknown-linux-gnu/arch/i386/_context.o] Error 127

@vib67
Copy link

vib67 commented Dec 28, 2012

It seems to be the error during the download of the source.some of the directory were not properly fetched.

@brson
Copy link
Author

brson commented Dec 28, 2012

@vib67 Glad you got it sorted out.

@brson
Copy link
Author

brson commented Apr 25, 2013

Closing this as we are working on it now.

@brson brson closed this as completed Apr 25, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants