John Cairns bio photo

John Cairns

John is an engineer, architect and mentor who focuses on extremly performance sensitive and ultra high volume applications.

Email Twitter Github

Benchmarking Conversant Disruptor

Conversant Disruptor is the fastest available Java BlockingQueue. A JMH benchmark comparing Conversant Disruptor versus ArrayBlockingQueue, LinkedTransferQueue and LMAX is available here.

The mean time for 1M transfers on ordinary hardware is 10ms. The multithread implementation averages 45ms.

In comparison, LMAX exhibited 22ms for single thread and 55ms in multithread mode. The BlockingQueues available in the Oracle JDK are not on par with either Disruptor. ArrayBlockingQueue consumes 300ms per million transfers, while LinkfedTransferQueue a CAS protected LinkedList can obtain 151ms for 1M transfers on average.

Test Setup

This benchmark uses JMH. JMH is a framework for microbenchmarking in Java. The same code is used for each BlockingQueue. However, LMAX Disruptor requires event preallocation as part of the queue configuration. We made an effort to keep the LMAX implementation as comparable as is possible within known API differences.

The test hardware is a consumer grade laptop, Intel Core i7-4600U @ 2.1Ghz. Better performance could easily be attained on enterprise class hardware. A thread pool is created with one thread per available processor, then information in the form of a Java Long is passed from the producer to the consumer via the queue. After processing a long sequence, 1 million entries, the total time to transfer all items is measured and the per transfer time is calculated.

Example Producer

for(int i = 0; i<Run.OFFER_COUNT; i++) {
    while(!msgQueue.offer(Run.LONGVAL, 1, TimeUnit.MICROSECONDS)) {
        Thread.yield();
    }
}

Example Consumer

for(int i = 0; i<Run.OFFER_COUNT; i++) {
    while(msgQueue.poll(1, TimeUnit.MICROSECONDS) != Run.LONGVAL) {
        Thread.yield();
    }
}

Our simple benchmark shows that with almost no configuration or specialized setup Conversant Disruptor is capable of 20ns push-pull transfers and 45ns multithread. Conversant Disruptor is ideal for any high performance application where either high volume or low latency is required. Example applications include extreme volume HTTP environments, financial exchanges, log offload processing, actor-reactor event processing and more.

This work confirms work done by Sabarish Sasidharan., and extends it to include Conversant Disruptor.

Conversant Disruptor is available on github.