[Pharo-project] Why atomic stuff rules :)

Igor Stasenko siguctua at gmail.com
Thu Oct 14 15:51:35 EDT 2010


In the attachment an implementation of SharedQueue3, which using
atomic operation.
Of course , currently it is based on assumption that some stuff (like
two assignments in a row) can't be interrupted.

The FIFO implementation using ASWP and CAS:

push:
 - no spins, 1 ASWP

pop:
 - 2 spins, 1 ASWP , 1 CAS


Here a simple bench i made, which pushing 100000 elements into queue
using 10 different processes,
and then looks how many are popped via 3 feeder processes during that time:

Squeak VM.

SharedQueue :

SharedQueue3Test new benchManyPushersAndFeeders: SharedQueue
'Added 100000 items, processed 30000 queue items during 1928 milliseconds'

SharedQueue2 :

SharedQueue3Test new benchManyPushersAndFeeders: SharedQueue2
'Added 100000 items, processed 30034 queue items during 1074 milliseconds'

SharedQueue3 (mine) :

SharedQueue3Test new benchManyPushersAndFeeders: SharedQueue3
'Added 100000 items, processed 70229 queue items during 118 milliseconds'


Cog:

SharedQueue3Test new benchManyPushersAndFeeders: SharedQueue
 'Added 100000 items, processed 29999 queue items during 1955 milliseconds'

SharedQueue3Test new benchManyPushersAndFeeders: SharedQueue2
'Added 100000 items, processed 29997 queue items during 197 milliseconds'

SharedQueue3Test new benchManyPushersAndFeeders: SharedQueue3
'Added 100000 items, processed 100000 queue items during 26 milliseconds'


if anyone has better ideas how to bench throughput, send me the code.


-- 
Best regards,
Igor Stasenko AKA sig.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: atomic queue.zip
Type: application/zip
Size: 2313 bytes
Desc: not available
URL: <http://lists.pharo.org/pipermail/pharo-dev_lists.pharo.org/attachments/20101014/4ff544ee/attachment.zip>


More information about the Pharo-dev mailing list