about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-02-14 00:26:47 -0800
committerbors <bors@rust-lang.org>2014-02-14 00:26:47 -0800
commit03b324ff4481255a371bb234fc3e53bcb8d08e7e (patch)
tree0ff6f6307f936d2b2eced588c60b3dd2bc568e6b /src/libstd
parent2fe7bfe4d2de9942449d3656317e66bc9ec50204 (diff)
parent2650b61505e5ed5ac3075451a73e64fd226f5b10 (diff)
downloadrust-03b324ff4481255a371bb234fc3e53bcb8d08e7e.tar.gz
rust-03b324ff4481255a371bb234fc3e53bcb8d08e7e.zip
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.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/rt/rtio.rs1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/libstd/rt/rtio.rs b/src/libstd/rt/rtio.rs
index 39623e329ea..5573f8ec02e 100644
--- a/src/libstd/rt/rtio.rs
+++ b/src/libstd/rt/rtio.rs
@@ -41,6 +41,7 @@ pub trait EventLoop {
 
     /// The asynchronous I/O services. Not all event loops may provide one.
     fn io<'a>(&'a mut self) -> Option<&'a mut IoFactory>;
+    fn has_active_io(&self) -> bool;
 }
 
 pub trait RemoteCallback {