about summary refs log tree commit diff
path: root/src/libstd/task/spawn.rs
AgeCommit message (Collapse)AuthorLines
2013-11-29Implement a lock-free work-stealing dequeAlex Crichton-3/+2
This adds an implementation of the Chase-Lev work-stealing deque to libstd under std::rt::deque. I've been unable to break the implementation of the deque itself, and it's not super highly optimized just yet (everything uses a SeqCst memory ordering). The major snag in implementing the chase-lev deque is that the buffers used to store data internally cannot get deallocated back to the OS. In the meantime, a shared buffer pool (synchronized by a normal mutex) is used to deallocate/allocate buffers from. This is done in hope of not overcommitting too much memory. It is in theory possible to eventually free the buffers, but one must be very careful in doing so. I was unable to get some good numbers from src/test/bench tests (I don't think many of them are slamming the work queue that much), but I was able to get some good numbers from one of my own tests. In a recent rewrite of select::select(), I found that my implementation was incredibly slow due to contention on the shared work queue. Upon switching to the parallel deque, I saw the contention drop to 0 and the runtime go from 1.6s to 0.9s with the most amount of time spent in libuv awakening the schedulers (plus allocations). Closes #4877
2013-11-27Improve the rt::thread moduleAlex Crichton-1/+1
* Added doc comments explaining what all public functionality does. * Added the ability to spawn a detached thread * Added the ability for the procs to return a value in 'join'
2013-11-26librustc: Make `||` lambdas not infer to `proc`sPatrick Walton-1/+1
2013-11-24Remove linked failure from the runtimeAlex Crichton-520/+11
The reasons for doing this are: * The model on which linked failure is based is inherently complex * The implementation is also very complex, and there are few remaining who fully understand the implementation * There are existing race conditions in the core context switching function of the scheduler, and possibly others. * It's unclear whether this model of linked failure maps well to a 1:1 threading model Linked failure is often a desired aspect of tasks, but we would like to take a much more conservative approach in re-implementing linked failure if at all. Closes #8674 Closes #8318 Closes #8863
2013-11-19libstd: Change all uses of `&fn(A)->B` over to `|A|->B` in libstdPatrick Walton-13/+15
2013-11-18libstd: Change all `~fn()`s to `proc`s in the standard library.Patrick Walton-5/+7
This makes `Cell`s no longer necessary in most cases.
2013-11-10Remove a debug! statement before I/O is readyAlex Crichton-1/+0
The logging macros all use libuv-based I/O, and there was one stray debug statement in task::spawn which was executing before the I/O context was ready. Remove it and add a test to make sure that we can continue to debug this sort of code. Closes #10405
2013-11-01Remove unnecessary unwind messagesAlex Crichton-3/+3
Now that the type_id intrinsic is working across crates, all of these unnecessary messages can be removed to have the failure type for a task truly be ~Any and only ~Any
2013-10-30Prepared `std::sys` for removal, and made `begin_unwind` simplerMarvin Löbel-4/+3
- `begin_unwind` is now generic over any `T: Any + Send`. - Every value you fail with gets boxed as an `~Any`. - Because of implementation details, `&'static str` and `~str` are still handled specially behind the scenes. - Changed the big macro source string in libsyntax to a raw string literal, and enabled doc comments there.
2013-10-29Move rust's uv implementation to its own crateAlex Crichton-9/+5
There are a few reasons that this is a desirable move to take: 1. Proof of concept that a third party event loop is possible 2. Clear separation of responsibility between rt::io and the uv-backend 3. Enforce in the future that the event loop is "pluggable" and replacable Here's a quick summary of the points of this pull request which make this possible: * Two new lang items were introduced: event_loop, and event_loop_factory. The idea of a "factory" is to define a function which can be called with no arguments and will return the new event loop as a trait object. This factory is emitted to the crate map when building an executable. The factory doesn't have to exist, and when it doesn't then an empty slot is in the crate map and a basic event loop with no I/O support is provided to the runtime. * When building an executable, then the rustuv crate will be linked by default (providing a default implementation of the event loop) via a similar method to injecting a dependency on libstd. This is currently the only location where the rustuv crate is ever linked. * There is a new #[no_uv] attribute (implied by #[no_std]) which denies implicitly linking to rustuv by default Closes #5019
2013-10-28Make some more rt components publicAlex Crichton-3/+7
Primarily this makes the Scheduler and all of its related interfaces public. The reason for doing this is that currently any extern event loops had no access to the scheduler at all. This allows third-party event loops to manipulate the scheduler, along with allowing the uv event loop to live inside of its own crate.
2013-10-28Allow fail messages to be caught, and introduce the Any traitMarvin Löbel-26/+34
Some code cleanup, sorting of import blocks Removed std::unstable::UnsafeArc's use of Either Added run-fail tests for the new FailWithCause impls Changed future_result and try to return Result<(), ~Any>. - Internally, there is an enum of possible fail messages passend around. - In case of linked failure or a string message, the ~Any gets lazyly allocated in future_results recv method. - For that, future result now returns a wrapper around a Port. - Moved and renamed task::TaskResult into rt::task::UnwindResult and made it an internal enum. - Introduced a replacement typedef `type TaskResult = Result<(), ~Any>`.
2013-10-24Migrate Rtio objects to true trait objectsAlex Crichton-2/+2
This moves as many as I could over to ~Trait instead of ~Typedef. The only remaining one is the IoFactoryObject which should be coming soon...
2013-10-23Removed Unnecessary comments and white spaces #4386reedlepee-1/+0
2013-10-23Making fields in std and extra : private #4386reedlepee-3/+4
2013-10-22Drop the '2' suffix from logging macrosAlex Crichton-6/+6
Who doesn't like a massive renaming?
2013-10-11De-pub some private runtime componentsAlex Crichton-7/+7
This change was waiting for privacy to get sorted out, which should be true now that #8215 has landed. Closes #4427
2013-10-09option: rewrite the API to use compositionDaniel Micay-8/+8
2013-10-07Fix existing privacy/visibility violationsAlex Crichton-8/+3
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-2/+2
2013-09-16switch Drop to `&mut self`Daniel Micay-33/+28
2013-08-27librustc: Ensure that type parameters are in the right positions in paths.Patrick Walton-5/+5
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-23auto merge of #8677 : bblum/rust/scratch, r=alexcrichtonbors-45/+32
r anybody; there isn't anything complicated here
2013-08-22Enabled unit tests in std and extra.Vadim Chugunov-3/+0
2013-08-20small cleanups in task/spawn.rsBen Blum-45/+32
2013-08-12Clean up transitionary glue in task/spawn.rs. Don't hold kill-little-lock ↵Ben Blum-129/+63
for O(n) time, cf #3100, and optimize out several unneeded clone()s.
2013-08-10Mass rename of .consume{,_iter}() to .move_iter()Erick Tryzelaar-5/+5
cc #7887
2013-08-09Remove the C++ runtime. SayonaraBrian Anderson-127/+16
2013-08-09std: Fix perf of local allocations in newschedBrian Anderson-9/+8
Mostly optimizing TLS accesses to bring local heap allocation performance closer to that of oldsched. It's not completely at parity but removing the branches involved in supporting oldsched and optimizing pthread_get/setspecific to instead use our dedicated TCB slot will probably make up for it.
2013-08-08Enabled workstealing in the scheduler. Previously we had one global work ↵toddaaro-1/+8
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-3/+3
2013-08-05Lazily initialize 'leaf node' taskgroups for unlinked spawns, for an ↵Ben Blum-45/+59
apparent 11% speedup.
2013-08-03remove obsolete `foreach` keywordDaniel Micay-5/+5
this has been replaced by `for`
2013-08-02std: Implement SingleThreaded spawn mode for newschedBrian Anderson-8/+80
2013-08-01A major refactoring that changes the way the runtime uses TLS. In thetoddaaro-30/+13
old design the TLS held the scheduler struct, and the scheduler struct held the active task. This posed all sorts of weird problems due to how we wanted to use the contents of TLS. The cleaner approach is to leave the active task in TLS and have the task hold the scheduler. To make this work out the scheduler has to run inside a regular task, and then once that is the case the context switching code is massively simplified, as instead of three possible paths there is only one. The logical flow is also easier to follow, as the scheduler struct acts somewhat like a "token" indicating what is active. These changes also necessitated changing a large number of runtime tests, and rewriting most of the runtime testing helpers. Polish level is "low", as I will very soon start on more scheduler changes that will require wiping the polish off. That being said there should be sufficient comments around anything complex to make this entirely respectable as a standalone commit.
2013-08-01std: Replace `for` with `do { .. }` expr where internal iterators are usedblake2-ppc-1/+2
2013-08-01auto merge of #8158 : bblum/rust/task-cleanup, r=brsonbors-0/+2
r? @brson
2013-08-01migrate many `for` loops to `foreach`Daniel Micay-5/+4
2013-07-31Give tasks useful names. #2891Ben Blum-0/+2
2013-07-31auto merge of #8139 : brson/rust/rm-old-task-apis, r=pcwaltonbors-32/+5
This removes a bunch of options from the task builder interface that are irrelevant to the new scheduler and were generally unused anyway. It also bumps the stack size of new scheduler tasks so that there's enough room to run rustc and changes the interface to `Thread` to not implicitly join threads on destruction, but instead require an explicit, and mandatory, call to `join`.
2013-07-30std: Remove foreign_stack_size spawn option. Irrelevant to future FFI changesBrian Anderson-7/+3
2013-07-30std: Remove CurrentScheduler spawn mode. UnusedBrian Anderson-11/+2
2013-07-30std: Remove ExistingScheduler spawn mode. UnusedBrian Anderson-4/+1
2013-07-30std: Remove PlatformThread spawn mode. ObsoleteBrian Anderson-4/+2
2013-07-30std: Remove ThreadPerTask spawn mode. UnimplementedBrian Anderson-4/+1
2013-07-30std: Remove ManualThreads spawn modeBrian Anderson-7/+1
2013-07-30Unkillable is not unsafe. Close #7832.Ben Blum-1/+1
2013-07-30(cleanup) Fix unimplemented message for kill_all in newsched.Ben Blum-2/+7
2013-07-27Change concurrency primitives to standard naming conventionsSteven Stewart-Gallus-5/+5
To be more specific: `UPPERCASETYPE` was changed to `UppercaseType` `type_new` was changed to `Type::new` `type_function(value)` was changed to `value.method()`