async-executor
async-executor copied to clipboard
Push task directly to the local queue
This was originally implemented in #37, but the implementation turned out to be very buggy so I removed it in #61. Still, I think it's an important optimization even for a reference executor, as it nearly doubles our performance in micro-benchmarks.
https://github.com/smol-rs/async-executor/blob/8a0832c090625dd36e66ff7b42a76a80b421f90f/src/lib.rs#L257
This might need to be reopened due to the revert in 1.10.
The main issue stems from tick-only use cases being unable to find tasks. For which there are some potential options for resolving that problem:
- Let tick steal tasks if it doesn't find any in the global queue. This might drive higher contention when ticking in a loop from multiple threads.
- Avoid pushing onto local queues while others are not listening to them.
- Split tick-able and run-able executors to isolate one use case from another. The former would strictly rely on the global queue, while the latter can be assured that tasks can be stolen if enqueued locally. This will likely require splitting the type or runtime checks, both of which would be breaking changes.
Given that try_tick might be removable in the breaking change, the last option there may be the best for performance across all other options.