typelevel / typelevel/cats-effect
Improve async `Queue` optimization by special-casing mpsc scenarios
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 2.2k
- Forks
- 576
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 18
Description
Most practical use-cases of Queue are multi-producer, single-consumer (mpsc), but since the API doesn't guarantee this, we have to pessimistically allow for multi-producer, multi-consumer (mpmc) cases. Mpmc queues are very complex and have certain performance implications which are theoretically worse than what you can do in single-consumer scenarios.
We should explore optimizing for single-consumer provided that we can maintain correctness in multi-consumer cases, even if it means that we actively deoptimize the multi-consumer cases. Striping is an obvious mechanism that comes to mind, but there are other techniques we can explore. Both UnsafeUnbounded and UnsafeBounded could stand to be adjusted, though the latter is probably more impactful than the former in the happy path scenario.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the Queue implementations for UnsafeUnbounded and UnsafeBounded, focusing on how they handle mpsc and mpmc usage. Explore candidate optimizations such as striping while preserving correctness for multi-consumer cases, and compare the performance impact on the single-consumer and multi-consumer paths.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100