ThePrimeagen / tyrone-biggums

Clearly a repo about websockets and their comparison...
Other
465 stars 56 forks source link

queue locks are so 2020 #13

Open ashtonian opened 2 years ago

ashtonian commented 2 years ago

removes the sync.mutex out of the message queue in favor of a lock less concurrent safe queue.

go fmt on the master branch seems out of date or something as go fmt now forces tabs. Merge #12 first to see actual changes. Or hit that ignore whitespace diff button

I think this in memory queue is faster than channels, but it doesn't block so it would require more refactoring likely with sleeps to handle an empty queue in order to replace all the channels with the queue implementation. This is very useful in real world environments where the queue is rarely starved. If the sleeps aren't tuned right and the queue was starved it would add latency over the channel implementation, however under significant load the queue would never starve and be faster than channels.