about summary refs log tree commit homepage
path: root/lib/rainbows/rev_thread_spawn.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-11-09 02:37:26 -0800
committerEric Wong <normalperson@yhbt.net>2009-11-09 02:50:04 -0800
commit692ae11f5814e318964f90db2087bd9d11563b20 (patch)
tree18aa7ba6de637422aa49ec0bb6c796efa93eabab /lib/rainbows/rev_thread_spawn.rb
parent8cd6f4d94503a568501b6e24bb785a8e002720c9 (diff)
downloadrainbows-692ae11f5814e318964f90db2087bd9d11563b20.tar.gz
Somehow 1.8 performance blows with shorter reads in the Rack
application.  This may be because the Rev framework uses
a default 16K IO size and our test applications may request
less.
Diffstat (limited to 'lib/rainbows/rev_thread_spawn.rb')
-rw-r--r--lib/rainbows/rev_thread_spawn.rb19
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/rainbows/rev_thread_spawn.rb b/lib/rainbows/rev_thread_spawn.rb
index f0482fd..4eba6d9 100644
--- a/lib/rainbows/rev_thread_spawn.rb
+++ b/lib/rainbows/rev_thread_spawn.rb
@@ -18,23 +18,24 @@ module Rainbows
   #
   # Caveats:
   #
-  # * TeeInput performance is currently terrible under Ruby 1.9.1-p243
-  #   with few, fast clients.  This appears to be due the Queue
-  #   implementation in 1.9.
+  # * TeeInput performance is terrible unless you match the
+  #   length argument of your env["rack.input"]#read calls
+  #   so that it is equal to Rev::IO::INPUT_SIZE
 
   module RevThreadSpawn
     class Client < Rainbows::Rev::Client
       include EvThreadCore
       LOOP = ::Rev::Loop.default
       DR = Rainbows::Rev::DeferredResponse
+      TEE_RESUMER = ::Rev::AsyncWatcher.new
 
       def pause
-        @lock.synchronize { detach }
+        @lock.synchronize { disable if enabled? }
       end
 
       def resume
-        # we always attach to the loop belonging to the main thread
-        @lock.synchronize { attach(LOOP) }
+        @lock.synchronize { enable unless enabled? }
+        TEE_RESUMER.signal
       end
 
       def write(data)
@@ -74,5 +75,11 @@ module Rainbows
     end
 
     include Rainbows::Rev::Core
+
+    def init_worker_process(worker)
+      super
+      Client::TEE_RESUMER.attach(::Rev::Loop.default)
+    end
+
   end
 end