about summary refs log tree commit homepage
path: root/lib/rainbows
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2012-05-09 21:11:39 +0000
committerEric Wong <normalperson@yhbt.net>2012-05-09 21:11:39 +0000
commit604f64f624d562f480dc8424a6597ec5b32947df (patch)
tree03e454eb2a7fa8f637a4ac5c97a58882ec7ccc4c /lib/rainbows
parent3e61265d4193340721dd53178c43c4fa24debb79 (diff)
downloadrainbows-604f64f624d562f480dc8424a6597ec5b32947df.tar.gz
Array#pop can be significantly faster than Array#shift on large
arrays (especially since we push into the Array).  This is
because Array#shift needs to shift all elements in the array,
and Array#pop only needs to shorten the array by one element.
The Fiber stack may also be hotter in CPU caches when we choose
the most-frequently used stack.
Diffstat (limited to 'lib/rainbows')
-rw-r--r--lib/rainbows/fiber_pool.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/rainbows/fiber_pool.rb b/lib/rainbows/fiber_pool.rb
index 64a638c..07a9faf 100644
--- a/lib/rainbows/fiber_pool.rb
+++ b/lib/rainbows/fiber_pool.rb
@@ -30,7 +30,7 @@ module Rainbows::FiberPool
 
     begin
       schedule do |l|
-        fib = pool.shift or break # let another worker process take it
+        fib = pool.pop or break # let another worker process take it
         if io = l.kgio_tryaccept
           fib.resume(io)
         else