about summary refs log tree commit diff
path: root/src/libstd/rt/sched.rs
AgeCommit message (Collapse)AuthorLines
2013-10-09option: rewrite the API to use compositionDaniel Micay-1/+1
2013-10-09std::rand: Minor clean-up of comments & add a missing default method.Huon Wilson-1/+0
2013-10-09Convert rt::sched::new_sched_rng to use open/read/close rather than f*.Huon Wilson-16/+10
2013-10-09std::rand: make the windows OSRng more correct, remove some C++.Huon Wilson-1/+2
This lets the C++ code in the rt handle the (slightly) tricky parts of random number generation: e.g. error detection/handling, and using the values of the `#define`d options to the various functions.
2013-10-09std::rand: Add a trait for seeding RNGs: SeedableRng.Huon Wilson-2/+2
This provides 2 methods: .reseed() and ::from_seed that modify and create respecitively. Implement this trait for the RNGs in the stdlib for which this makes sense.
2013-10-09std::rand: Add OSRng, ReaderRng wrappers around the OS RNG & generic Readers ↵Huon Wilson-1/+55
respectively. The former reads from e.g. /dev/urandom, the latter just wraps any std::rt::io::Reader into an interface that implements Rng. This also adds Rng.fill_bytes for efficient implementations of the above (reading 8 bytes at a time is inefficient when you can read 1000), and removes the dependence on src/rt (i.e. rand_gen_seed) although this last one requires implementing hand-seeding of the XorShiftRng used in the scheduler on Linux/unixes, since OSRng relies on a scheduler existing to be able to read from /dev/urandom.
2013-10-07Fix existing privacy/visibility violationsAlex Crichton-0/+6
This commit fixes all of the fallout of the previous commit which is an attempt to refine privacy. There were a few unfortunate leaks which now must be plugged, and the most horrible one is the current `shouldnt_be_public` module now inside `std::rt`. I think that this either needs a slight reorganization of the runtime, or otherwise it needs to just wait for the external users of these modules to get replaced with their `rt` implementations. Other fixes involve making things pub which should be pub, and otherwise updating error messages that now reference privacy instead of referencing an "unresolved name" (yay!).
2013-09-30std: Remove usage of fmt!Alex Crichton-8/+8
2013-09-27Suppress warning by removing unused importFlavio Percoco-1/+0
2013-09-25std::rt: Implement task yielding. Fix a starvation problemBrian Anderson-28/+129
2013-09-22disable starvation test completely for nowDaniel Micay-13/+10
this is still broken on the bsd builder, perhaps because it has 1 core
2013-09-22disable scheduler starvation test on valgrindDaniel Micay-9/+13
2013-09-23std: merge rand::{Rng,RngUtil} with default methods.Huon Wilson-2/+2
Also, documentation & general clean-up: - remove `gen_char_from`: better served by `sample` or `choose`. - `gen_bytes` generalised to `gen_vec`. - `gen_int_range`/`gen_uint_range` merged into `gen_integer_range` and made to be properly uniformly distributed. Fixes #8644. Minor adjustments to other functions.
2013-09-19std::rt: Try stealing from all schedulersBrian Anderson-10/+27
This guarantees that if there is work to do it will be found
2013-09-16switch Drop to `&mut self`Daniel Micay-3/+3
2013-09-09rename `std::iterator` to `std::iter`Daniel Micay-1/+1
The trait will keep the `Iterator` naming, but a more concise module name makes using the free functions less verbose. The module will define iterables in addition to iterators, as it deals with iteration in general.
2013-08-29Remove the iter module.Jason Fager-1/+1
Moves the Times trait to num while the question of whether it should exist at all gets hashed out as a completely separate question.
2013-08-27librustc: Fix merge falloutPatrick Walton-2/+2
2013-08-27libstd: Fix merge fallout.Patrick Walton-1/+1
2013-08-27librustc: Stop calling `each_path` in coherence.Patrick Walton-1/+1
10% win or so for small crates.
2013-08-27librustc: Ensure that type parameters are in the right positions in paths.Patrick Walton-9/+9
This removes the stacking of type parameters that occurs when invoking trait methods, and fixes all places in the standard library that were relying on it. It is somewhat awkward in places; I think we'll probably want something like the `Foo::<for T>::new()` syntax.
2013-08-27librustc: Remove `&const` and `*const` from the language.Patrick Walton-0/+1
They are still present as part of the borrow check.
2013-08-24std::rt: Remove metrics for perfBrian Anderson-5/+0
These aren't used for anything at the moment and cause some TLS hits on some perf-critical code paths. Will need to put better thought into it in the future.
2013-08-24std::rt: Reduce MessageQueue contentionBrian Anderson-4/+27
It's not a huge win but it does reduce the amount of time spent contesting the message queue when the schedulers are under load
2013-08-24std::rt: Reduce SleeperList contentionBrian Anderson-4/+1
This makes the lock much less contended. In the test I'm running the number of times it's contended goes from ~100000 down to ~1000.
2013-08-24std::rt: Optimize TLS use in change_task_contextBrian Anderson-1/+3
2013-08-23std: Convert some assert!s to rtassert!Brian Anderson-1/+1
2013-08-23std: Reduce TLS accessBrian Anderson-3/+2
2013-08-20auto merge of #8656 : toddaaro/rust/idle-opt+cleaning, r=brsonbors-13/+16
Fixed a memory leak caused by the singleton idle callback failing to close correctly. The problem was that the close function requires running inside a callback in the event loop, but we were trying to close the idle watcher after the loop returned from run. The fix was to just call run again to process this callback. There is an additional tweak to move the initialization logic fully into bootstrap, so tasks that do not ever call run do not have problems destructing.
2013-08-20Fixed a memory leak caused by the singleton idle callback failing to close ↵toddaaro-13/+16
correctly. The problem was that the close function requires running inside a callback in the event loop, but we were trying to close the idle watcher after the loop returned from run. The fix was to just call run again to process this callback. There is an additional tweak to move the initialization logic fully into bootstrap, so tasks that do not ever call run do not have problems destructing.
2013-08-20auto merge of #8566 : toddaaro/rust/idle-opt+cleaning, r=catamorphism,brsonbors-287/+280
Instead of a furious storm of idle callbacks we just have one. This is a major performance gain - around 40% on my machine for the ping pong bench. Also in this PR is a cleanup commit for the scheduler code. Was previously up as a separate PR, but bors load + imminent merge hell led me to roll them together. Was #8549.
2013-08-19Try to fix mac valgrind bot by disabling thread-heavy activities.Graydon Hoare-0/+2
2013-08-19clean whitespace :/toddaaro-3/+3
2013-08-16A round of code cleaning for the primary scheduler code. Comments have been ↵toddaaro-272/+199
updated, a minor amount of support type restructing has happened, methods have been reordered, and some duplicate code has been purged.
2013-08-16Moved the logic for a pausible idle callback into a new type - ↵toddaaro-73/+23
PausibleIdleCallback and placed the appropriate signatures in rtio and implementation into uvio.
2013-08-16std::rt: Fix a race in UvRemoteCallback's dtor that misses callbacksBrian Anderson-0/+46
Full description in comments.
2013-08-16std::rt: Touch up idle logicBrian Anderson-16/+36
2013-08-16an attempt at a singleton pausible idle callback for each scheduler. suffers ↵toddaaro-19/+69
from nondeterministic deadlock and also pending scheduler messages on scheduler shutdown.
2013-08-08Enabled workstealing in the scheduler. Previously we had one global work ↵toddaaro-45/+114
queue shared by each scheduler. Now there is a separate work queue for each scheduler, and work is "stolen" from other queues when it is exhausted locally.
2013-08-07std: Allow spawners to specify stack sizeBrian Anderson-7/+7
2013-08-07core: option.map_consume -> option.map_moveErick Tryzelaar-2/+2
2013-08-04std::rt: Schedule more scheduler callbacks to avoid dropping messagesBrian Anderson-1/+3
2013-08-04std::rt: Don't allow schedulers to exit before handling all messagesBrian Anderson-0/+10
Every time run_sched_once performs a 'scheduling action' it needs to guarantee that it runs at least one more time, so enqueue another run_sched_once callback. The primary reason it needs to do this is because not all async callbacks are guaranteed to run, it's only guaranteed that *a* callback will run after enqueing one - some may get dropped. At the moment this means we wastefully create lots of callbacks to ensure that there will *definitely* be a callback queued up to continue running the scheduler. The logic really needs to be tightened up here.
2013-08-03remove obsolete `foreach` keywordDaniel Micay-2/+2
this has been replaced by `for`
2013-08-02Add an assert_may_sleep() check on every context switch.Ben Blum-0/+4
2013-08-02Don't fail from kill signals if already unwinding.Ben Blum-1/+1
2013-08-02auto merge of #8221 : brson/rust/single-threaded, r=graydonbors-3/+9
This is the last major runtime feature needed for the transition to the new scheduler.
2013-08-02std: Implement SingleThreaded spawn mode for newschedBrian Anderson-3/+9
2013-08-02replace `range` with an external iteratorDaniel Micay-4/+3
2013-08-01fixed incorrect handling of returned scheduler option and restructed ↵toddaaro-63/+46
scheduler functions slightly