about summary refs log tree commit diff
path: root/src/libstd/rt/task.rs
AgeCommit message (Collapse)AuthorLines
2013-11-28Register new snapshotsAlex Crichton-4/+4
2013-11-26librustc: Make `||` lambdas not infer to `proc`sPatrick Walton-3/+3
2013-11-26libstd: Remove all non-`proc` uses of `do` from libstdPatrick Walton-16/+16
2013-11-24Remove linked failure from the runtimeAlex Crichton-27/+3
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-3/+3
2013-11-18libstd: Change all `~fn()`s to `proc`s in the standard library.Patrick Walton-11/+20
This makes `Cell`s no longer necessary in most cases.
2013-11-11Move std::rt::io to std::ioAlex Crichton-1/+1
2013-11-11Remove #[fixed_stack_segment] and #[rust_stack]Alex Crichton-6/+2
These two attributes are no longer useful now that Rust has decided to leave segmented stacks behind. It is assumed that the rust task's stack is always large enough to make an FFI call (due to the stack being very large). There's always the case of stack overflow, however, to consider. This does not change the behavior of stack overflow in Rust. This is still normally triggered by the __morestack function and aborts the whole process. C stack overflow will continue to corrupt the stack, however (as it did before this commit as well). The future improvement of a guard page at the end of every rust stack is still unimplemented and is intended to be the mechanism through which we attempt to detect C stack overflow. Closes #8822 Closes #10155
2013-11-10Clean up the remaining chunks of uvAlex Crichton-4/+5
2013-11-01Remove unnecessary unwind messagesAlex Crichton-53/+24
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-19/+52
- `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-28rt::task: Make current_stack_segment public againKeegan McAllister-1/+4
This was done in 2145de8c and reverted in 0ada7c7f, but Servo needs it. Closes #10065.
2013-10-28Allow fail messages to be caught, and introduce the Any traitMarvin Löbel-50/+124
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-25auto merge of #10060 : alexcrichton/rust/cached-stdout, r=brsonbors-5/+22
Almost all languages provide some form of buffering of the stdout stream, and this commit adds this feature for rust. A handle to stdout is lazily initialized in the Task structure as a buffered owned Writer trait object. The buffer behavior depends on where stdout is directed to. Like C, this line-buffers the stream when the output goes to a terminal (flushes on newlines), and also like C this uses a fixed-size buffer when output is not directed at a terminal. We may decide the fixed-size buffering is overkill, but it certainly does reduce write syscall counts when piping output elsewhere. This is a *huge* benefit to any code using logging macros or the printing macros. Formatting emits calls to `write` very frequently, and to have each of them backed by a write syscall was very expensive. In a local benchmark of printing 10000 lines of "what" to stdout, I got the following timings: when | terminal | redirected ----------|---------------|-------- before | 0.575s | 0.525s after | 0.197s | 0.013s C | 0.019s | 0.004s I can also confirm that we're buffering the output appropriately in both situtations. We're still far slower than C, but I believe much of that has to do with the "homing" that all tasks due, we're still performing an order of magnitude more write syscalls than C does.
2013-10-25Cache and buffer stdout per-task for printingAlex Crichton-5/+22
Almost all languages provide some form of buffering of the stdout stream, and this commit adds this feature for rust. A handle to stdout is lazily initialized in the Task structure as a buffered owned Writer trait object. The buffer behavior depends on where stdout is directed to. Like C, this line-buffers the stream when the output goes to a terminal (flushes on newlines), and also like C this uses a fixed-size buffer when output is not directed at a terminal. We may decide the fixed-size buffering is overkill, but it certainly does reduce write syscall counts when piping output elsewhere. This is a *huge* benefit to any code using logging macros or the printing macros. Formatting emits calls to `write` very frequently, and to have each of them backed by a write syscall was very expensive. In a local benchmark of printing 10000 lines of "what" to stdout, I got the following timings: when | terminal | redirected ---------------------------------- before | 0.575s | 0.525s after | 0.197s | 0.013s C | 0.019s | 0.004s I can also confirm that we're buffering the output appropriately in both situtations. We're still far slower than C, but I believe much of that has to do with the "homing" that all tasks due, we're still performing an order of magnitude more write syscalls than C does.
2013-10-24Implement a basic event loop built on LittleLockAlex Crichton-2/+2
It's not guaranteed that there will always be an event loop to run, and this implementation will serve as an incredibly basic one which does not provide any I/O, but allows the scheduler to still run. cc #9128
2013-10-24Another round of test fixes and merge conflictsAlex Crichton-3/+6
2013-10-24Stop logging task failure to task loggersAlex Crichton-8/+10
The isn't an ideal patch, and the comment why is in the code. Basically uvio uses task::unkillable which touches the kill flag for a task, and if the task is failing due to mismangement of the kill flag, then there will be serious problems when the task tries to print that it's failing.
2013-10-24Move as much I/O as possible off of native::ioAlex Crichton-23/+21
When uv's TTY I/O is used for the stdio streams, the file descriptors are put into a non-blocking mode. This means that other concurrent writes to the same stream can fail with EAGAIN or EWOULDBLOCK. By all I/O to event-loop I/O, we avoid this error. There is one location which cannot move, which is the runtime's dumb_println function. This was implemented to handle the EAGAIN and EWOULDBLOCK errors and simply retry again and again.
2013-10-23Removed unnecessary comments and white spaces as suggestedreedlepee-13/+13
2013-10-23Removed Unnecessary comments and white spaces #4386reedlepee-4/+0
2013-10-23Making fields in std and extra : private #4386reedlepee-14/+18
2013-10-22Drop the '2' suffix from logging macrosAlex Crichton-3/+3
Who doesn't like a massive renaming?
2013-10-19auto merge of #9834 : alexcrichton/rust/morestack, r=brsonbors-8/+94
This commit re-introduces the functionality of __morestack in a way that it was not originally anticipated. Rust does not currently have segmented stacks, rather just large stack segments. We do not detect when these stack segments are overrun currently, but this commit leverages __morestack in order to check this. This commit purges a lot of the old __morestack and stack limit C++ functionality, migrating the necessary chunks to rust. The stack limit is now entirely maintained in rust, and the "main logic bits" of __morestack are now also implemented in rust as well. I put my best effort into validating that this currently builds and runs successfully on osx and linux 32/64 bit, but I was unable to get this working on windows. We never did have unwinding through __morestack frames, and although I tried poking at it for a bit, I was unable to understand why we don't get unwinding right now. A focus of this commit is to implement as much of the logic in rust as possible. This involved some liberal usage of `no_split_stack` in various locations, along with some use of the `asm!` macro (scary). I modified a bit of C++ to stop calling `record_sp_limit` because this is no longer defined in C++, rather in rust. Another consequence of this commit is that `thread_local_storage::{get, set}` must both be flagged with `#[rust_stack]`. I've briefly looked at the implementations on osx/linux/windows to ensure that they're pretty small stacks, and I'm pretty sure that they're definitely less than 20K stacks, so we probably don't have a lot to worry about. Other things worthy of note: * The default stack size is now 4MB instead of 2MB. This is so that when we request 2MB to call a C function you don't immediately overflow because you have consumed any stack at all. * `asm!` is actually pretty cool, maybe we could actually define context switching with it? * I wanted to add links to the internet about all this jazz of storing information in TLS, but I was only able to find a link for the windows implementation. Otherwise my suggestion is just "disassemble on that arch and see what happens" * I put my best effort forward on arm/mips to tweak __morestack correctly, we have no ability to test this so an extra set of eyes would be useful on these spots. * This is all really tricky stuff, so I tried to put as many comments as I thought were necessary, but if anything is still unclear (or I completely forgot to take something into account), I'm willing to write more!
2013-10-19Use __morestack to detect stack overflowAlex Crichton-8/+94
This commit resumes management of the stack boundaries and limits when switching between tasks. This additionally leverages the __morestack function to run code on "stack overflow". The current behavior is to abort the process, but this is probably not the best behavior in the long term (for deails, see the comment I wrote up in the stack exhaustion routine).
2013-10-18Made `std::task::TaskBuilder::future_result()` easier to useMarvin Löbel-25/+0
2013-10-11De-pub some private runtime componentsAlex Crichton-1/+43
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-2/+2
2013-10-09std::rand: Add an implementation of ISAAC64.Huon Wilson-1/+1
This is 2x faster on 64-bit computers at generating anything larger than 32-bits. It has been verified against the canonical C implementation from the website of the creator of ISAAC64. Also, move `Rng.next` to `Rng.next_u32` and add `Rng.next_u64` to take full advantage of the wider word width; otherwise Isaac64 will always be squeezed down into a u32 wasting half the entropy and offering no advantage over the 32-bit variant.
2013-10-05Make a task name use a `SendStr`, allowing for eitherMarvin Löbel-2/+2
static or owned strings
2013-09-30std: Remove usage of fmt!Alex Crichton-6/+6
2013-09-18Register new snapshotsAlex Crichton-9/+2
2013-09-16switch Drop to `&mut self`Daniel Micay-1/+1
2013-08-27Consolidate local_data implementations, and cleanupAlex Crichton-15/+14
This moves all local_data stuff into the `local_data` module and only that module alone. It also removes a fair amount of "super-unsafe" code in favor of just vanilla code generated by the compiler at the same time. Closes #8113
2013-08-27librustc: Ensure that type parameters are in the right positions in paths.Patrick Walton-6/+6
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-24std::rt: Remove an unnecessary allocation from the main sched loopBrian Anderson-11/+11
2013-08-21Adjust callbacks in the libraries for the new type of extern fnsNiko Matsakis-1/+10
cc #3678
2013-08-20auto merge of #8566 : toddaaro/rust/idle-opt+cleaning, r=catamorphism,brsonbors-1/+1
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-19std: Restore dynamic borrow trackingBrian Anderson-4/+14
2013-08-19Add externfn macro and correctly label fixed_stack_segmentsNiko Matsakis-0/+2
2013-08-16A round of code cleaning for the primary scheduler code. Comments have been ↵toddaaro-1/+1
updated, a minor amount of support type restructing has happened, methods have been reordered, and some duplicate code has been purged.
2013-08-16doc: correct spelling in documentation.Huon Wilson-2/+1
2013-08-13auto merge of #8475 : kmcallister/rust/stack_segment, r=brson,brsonbors-1/+1
Servo needs to tell SpiderMonkey about the stack bounds. r? @brson
2013-08-12rt::task: Make current_stack_segment publicKeegan McAllister-1/+1
Servo needs to tell SpiderMonkey about the stack bounds.
2013-08-12Clean up transitionary glue in task/spawn.rs. Don't hold kill-little-lock ↵Ben Blum-6/+4
for O(n) time, cf #3100, and optimize out several unneeded clone()s.
2013-08-09Remove the C++ runtime. SayonaraBrian Anderson-2/+2
2013-08-07std: Allow spawners to specify stack sizeBrian Anderson-14/+23
2013-08-07std::rt: Pull RUST_MIN_STACK from the environmentBrian Anderson-3/+3
2013-08-07std::rt: 2MB stacks againBrian Anderson-1/+1
2013-08-07std: add result.map_move, result.map_err_moveErick Tryzelaar-2/+2