]> git.lizzy.rs Git - rust.git/commit
auto merge of #12186 : alexcrichton/rust/no-sleep-2, r=brson
authorbors <bors@rust-lang.org>
Fri, 14 Feb 2014 08:26:47 +0000 (00:26 -0800)
committerbors <bors@rust-lang.org>
Fri, 14 Feb 2014 08:26:47 +0000 (00:26 -0800)
commit03b324ff4481255a371bb234fc3e53bcb8d08e7e
tree0ff6f6307f936d2b2eced588c60b3dd2bc568e6b
parent2fe7bfe4d2de9942449d3656317e66bc9ec50204
parent2650b61505e5ed5ac3075451a73e64fd226f5b10
auto merge of #12186 : alexcrichton/rust/no-sleep-2, r=brson

Any single-threaded task benchmark will spend a good chunk of time in `kqueue()` on osx and `epoll()` on linux, and the reason for this is that each time a task is terminated it will hit the syscall. When a task terminates, it context switches back to the scheduler thread, and the scheduler thread falls out of `run_sched_once` whenever it figures out that it did some work.

If we know that `epoll()` will return nothing, then we can continue to do work locally (only while there's work to be done). We must fall back to `epoll()` whenever there's active I/O in order to check whether it's ready or not, but without that (which is largely the case in benchmarks), we can prevent the costly syscall and can get a nice speedup.

I've separated the commits into preparation for this change and then the change itself, the last commit message has more details.
src/libgreen/sched.rs
src/librustuv/lib.rs