"To learn and then practice it time and again is a pleasure, is it not? To have friends come from afar to share each others learning is a pleasure, is it not? To be unperturbed when not appreciated by others is gentlemanly, is it not?" - Analects 1:1It is obvious to me the old man was talking about open source software, where we repeat what we learn, share with friends from afar, and try and behave when no one seems to get it. In this spirit I am going to try and apply lessons learnt and put together a concurrent queues library for Java - Java Alternative Queues.
It's early stages, but at this point I would value some feedback on:
- Interfaces and usability
- Project roadmap
When concurrent queues are concerned, it is my opinion that the JDK offering has been robust, but too generic to benefit from the performance gains offered by a more explicit declaration of requirements. JAQ would tackle this by providing queues through a requirements focused factory interface allowing the user to specify upfront:
- Number of producers/consumers
- Growth: Bounded/Unbounded
- Ordering (FIFO/other)
- Prefer throughput/latency
Interfaces and UsabilityI like the idea of separating several entities here:
- ConcurrentQueueFactory - Tell me what you need, through a ConcurrentQueueSpec.
- ConcurrentQueue - The queue data structure, provided by the factory. At the moment it does nothing but hand out producer/consumer instances. This is where pesky methods such as size/contains may end up. I'm not keen on supporting the full Queue interface so feedback on what people consider essential will be good.
- ConcurrentQueueConsumer - A consumer interface into the queue, provided by the queue. I'm planning to support several consumption styles,.
- ConcurrentQueueProducer - A producer interface into the queue, provided by the queue.
I realize this goes against the current Queue interface, but part of the whole point here is that the more we know about the calling code the better performance/correctness we can hope to offer.
I'd like to tackle the work in roughly the following order:
- Specify/document/settle on high level interfaces (initial cut done)
- SPSC implementations/tests/benchmarks (good bounded SPSC implementation is done, some benchmarks)
- MPSC implementations/tests/benchmarks (some bounded MPSC variants are included but not integrated)
- SPMC implementations/tests/benchmarks (not started)
- MPMC implementations/tests/benchmarks (not started)
I'm using JMH (and getting valuable support from @shipilev) for benchmarking the queues and hoping to use JCStress to test multi-threaded correctness.
I know I'll be using this library in the near future for a few projects, but I hope it will be generally useful so your feedback, comments and observations are very welcome. I've not been involved much in open-source projects before, so any advise on project setup is also welcome. Finally, if you feel like wading in and cutting some code, adding some tests or benchmarks, reporting some bugs or expressing interest in features BRING IT ON :-) pull requests are very welcome.