Real-world scenario: EventMachine uses Array as queue for EM.next_tick and EM::Queue, and when number of simultaneous requests goes over 200,
EventMachine becomes to be slower simply because of non-linear Array behavior in such pattern. With number of connections over 1000 the performance
loss could be over 20-30% simply cause of this issue.
(note that EM 0.12.0 used technique with flipping arrays to avoid this issue, but 1.0.0.beta uses #push/#shift on the same array)
Same issue were counted with usage of ::Queue :
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/391324 - it simply become to throttle at some
point cause it also uses Array as a storage. With this patch, ::Queue performance remains stable all over the time.
Excuse me for not doing testing other than on Ubuntu 12.04 64bit (I have no other machine at the moment). `make check` seem to run smoothly on this platform,
and I see no crossplatform reasons for them to fail on others.
Benchmark script mentioned as motivation
https://gist.github.com/2052650#file_ary_as_queue.rb could be used as microbenchmark.
I suppose that with count parameter as 2 it perfectly simulates typical queue loads in EventMachine (and I think, in ::Queue usage also).
среда, 27 июня 2012 г., 23:34:12 UTC+4 пользователь Jon написал: