[squeak-dev] SharedQueue doesn't scale

Igor Stasenko siguctua at gmail.com
Sat Oct 16 02:19:47 UTC 2010


Hello,

just out of interest, i tried to compare the speed of my FIFOQueue
implementation and SharedQueue,
using Levente's benchmarks for stack:

"The linked Stack implementation"
(1 to: 5) collect: [ :run |
       | stack |
       Smalltalk garbageCollect.
       stack := FIFOQueue new.
       {
               [ 1 to: 1000000 do: [ :each | stack nextPut: each ] ] timeToRun.
               [ 1 to: 1000000 do: [ :each | stack next ] ] timeToRun } ]

 #(#(291 69) #(170 65) #(168 66) #(168 65) #(168 65))

Then i changed FIFOQueue  to SharedQueue and run it again..
waiting 1 minute.. wait a bit more.. then i came to smoke.. and after
returning, it was still running..
i interrupted it, and inspected the queue size.. it was slightly above
300000 items.

Of course, SharedQueue usually not used in scenarios, where you need
to push such large number of items.
So, its just a warning.

Btw, here is another comparison (Stack vs thread-safe LIFO queue):

(1 to: 5) collect: [ :run |
       | stack |
       Smalltalk garbageCollect.
       stack := Stack new.
       {
               [ 1 to: 1000000 do: [ :each | stack push: each ] ] timeToRun.
               [ 1 to: 1000000 do: [ :each | stack pop ] ] timeToRun } ]

Stack:
   #(#(166 94) #(160 90) #(162 91) #(162 92) #(160 92))

LIFOQueue:
 #(#(172 250) #(174 248) #(172 250) #(174 252) #(172 250))

Yes, it is slower (mainly for reading). But it is price for being thread safe :)


-- 
Best regards,
Igor Stasenko AKA sig.



More information about the Squeak-dev mailing list