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.