smol-rs / concurrent-queue

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

Investigate ways to make `steal` from `async-executor` more efficient #69

Open fogti opened 4 months ago

fogti commented 4 months ago

It appears that a large amount of time in async-executor is spent shuffling around tasks between different queues. It would be interesting if there are ways to make such stealing of half of a queue faster, perhaps by making such a function part of this crate and utilize knowledge about internals to make such "mass-moves" faster.

notgull commented 4 months ago

concurrent-queue is ill-suited for this purpose. My plan was to use a dedicated work-stealing queue like crossbeam-deque.

james7132 commented 4 months ago

I just attempted this and crossbeam-deque requires an additional function on their Worker or Stealer that supports checking if they're pointing to the same underlying queue (like Arc::ptr_eq) or we risk having a worker steal from itself or failing to remove stealers when dropping a Runner.