Skip to content

Conversation

@aashish2384
Copy link

Hi @rezabrizi : First of all thanks for creating this github repo, It gave me very good introduction to lock free programming.
On this similar principle I wrote a pretty simple SPSC lock free queue, which also uses block version number concept to protecting read and write.

In summary following is the logic of my SPSC queue:

  1. If block version number is 1 , it means reader can perform read on this block and once done needs to set the version to 0
  2. If block version number is 0, that means no reader is currently acting on this block, and this is safe to write. once done the version will be increased to 1.
  3. Reader and writer index are separate as this is SPSC queue , so no need to make these indexes atomics.

When I ran benchmark , I see my queue is able to produce ~120 millions messages, whereas your SPMC queue(tested only 1 producer and 1 consumer ) is able to generate ~500+ millions messages during the same 5 seconds of run.

Could you kindly check my source code(hardly 60 lines) and provide your valuable insight on where my queue is suffering from performance bottleneck ?

@aashish2384
Copy link
Author

@rezabrizi : Kindly check the proposed alternative implementation and please provide your valuable insight on why this implementation is performing 5x slower than your implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant