smol-rs / concurrent-queue

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

Remove the heap allocation from non-single queues #52

Closed notgull closed 9 months ago

notgull commented 10 months ago

This appears to have been added in https://github.com/smol-rs/concurrent-queue/commit/ee83323156e5b256819efd4e7e2058376ccf77f9, possibly in response to the Clippy warning that shows up otherwise

https://github.com/smol-rs/concurrent-queue/blob/22b5e83c4fbd126eddc1990647d0ce35ee754467/src/lib.rs#L106

There is a useless heap allocation here that only serves to equalize the sizes of the ConcurrentQueue enum arms. As this queue is usually just shoved into a heap allocation for another structure, it seems like a waste of a heap allocation. Especially since only around four words of memory are wasted in the worse case, assuming a T with a size of a word.

mamaicode commented 10 months ago

Taking this on myself

notgull commented 9 months ago

Closes in #53