smol-rs / concurrent-queue

Concurrent multi-producer multi-consumer queue
Apache License 2.0
254 stars 21 forks source link

feat: Add ZST optimization to `ConcurrentQueue` #32

Closed notgull closed 1 year ago

notgull commented 1 year ago

This PR adds optimizations for zero-sized types to ConcurrentQueue, such that the queue essentially just becomes an AtomicUsize describing the number of elements in the queue.

notgull commented 1 year ago

Strange; it look like the ZST optimization is faster for the uncontended use case, but appears to be slower in any case involving multiple threads? Maybe it's because of the single contended atomic variable. I'm closing this for now.