From 604f64f624d562f480dc8424a6597ec5b32947df Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 9 May 2012 21:11:39 +0000 Subject: fiber_pool: take Fibers from larger pools faster 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. --- lib/rainbows/fiber_pool.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/rainbows') 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 -- cgit v1.2.3-24-ge0c7