-
Notifications
You must be signed in to change notification settings - Fork 48
Home
Disruptor is the highest performing intra-thread transfer mechanism available in Java. Conversant Disruptor is the highest performing implementation of this type of ring buffer queue because it has almost no overhead and it exploits a particularly simple design.
The Conversant Disruptor is designed to be fast by exploiting only cache level optimizations while keeping the overall approach to thread transfers direct and simple. The main advantage of the Conversant Disruptor over other Disruptor implementations is that it is based on the Java BlockingQueue
interface so existing software can be immediately adapted to use this disruptor without significant programming changes.
Conversant Disruptor is a drop in replacement for ArrayBlockingQueue
with an order of magnitude better performance. In comparison with LinkedTransferQueue
this disruptor implementation is roughly two times faster and does not allocate any objects internally. Given that LinkedTransferQueue
is state of the art in Java performance, Conversant Disruptor may yield significant performance improvements for applications that rely on fast intra-thread transfers.
Conversant Disruptor is capable of 4ns intra-thread transfers for push-pull senarios and 20ns multi-thread transfers in an 1 to N senario. The disruptor approach is sensitive to huge numbers of threads and will not exhibit good performance if your application exploits hundreds or thousands of waiting threads. Waiting threads will spin-lock the CPU. From a performance perspective, designing applications to exploit hundreds or thousands of waiting threads is never advisable.
Getting started with Conversant Disruptor is easy! Simply download and build the Java package. Once you have included the dependency in your project, you may use the Conversant Disruptor as you would any other Java BlockingQueue
.
Conversant Disruptor comes in two flavors: PushPull
and Multithread
. PushPull
is designed to work in the special case where there is only one producer thread and one consumer thread present. It is critical that this requirement is met, because the performance advantage of the PushPull
implementation comes at the cost of not being thread safe for multiple producer or consumer threads. If you access the PushPull
implementation with multiple simultaneous threads data will be lost.
The Multithread
implementation provides a full blocking queue implementation which may be used with multiple producer and consumer threads, however keep in mind that performance is degraded as the number of threads increase. This is a natural artifact of the disruptor strategy because most of performance comes from a particular thread obtaining the shared context by chance. The number of threads should be kept to a minimum. Ultimately there is a 5x performance penalty for using the Multithread
version even for a push-pull scenario.
Conversant Disruptor provides four different implementations. The ConcurrentQueue
implementations provide the rudimentary queuing functionality without any of the timing or waiting functionality spec'd by Java's api. This is useful if you are developing an application that will utilize spin locking or where timed waiting is not needed. The BlockingQueue
implementations provide full support of the Java BlockingQueue
interface including blocking and waiting timing support.