Chronicle Ring vs LMAX Disruptor

Introduction

Chronicle RingZero is a specialised lightweight, high-performance ring buffer specifically for the common use case of a single writer and single reader. Chronicle RingZero is available in both Java and C++, enabling full interoperability between applications in either language. Chronicle RingZero is one part of the Chronicle suite of low-latency Java and C++ libraries and software products, which also includes more generalised Ring implementations to cover multiple readers and writers.

The RingZero features are as follows:

  • A fixed number of slots (which must be a power of 2)
  • A maximum fixed message size per slot
  • Single writer, single reader (concurrent)
  • All writes must be from the same thread
  • All reads must be from the same thread

The LMAX Ring Buffer is part of the Java Disruptor library, and this document provides a comparison between this implementation and Java Chronicle RingZero.

Test Methodology

The test measured the write-to-read latency between two threads sharing data using either a Chronicle RingZero or LMAX Disruptor ring buffer. 15M messages were sent at varying message rates from 250k to 2M msgs/s. The messages were intentionally kept to just 12 bytes (1 int for indexing, 1 long for the nanosecond timestamp) in order to minimise fixed overheads from copying data and so better highlight the differences between the underlying ring implementations. The first 100k messages were discarded from the test to remove effects from JVM warmup.

All tests were run on a 2×12 core Xeon E5-2650 v4 @ 2.20GHz, with cores 2-11 isolated. The test process was assigned isolated cores, and no other processes were running in the isolated set. The Chronicle RingZero test used the Chronicle Affinity library to manage thread pinning, whereas the LMAX Disruptor test used external taskset (in the absence of equivalent controls exposed by the LMAX library itself).

Results

The write-to-read latency results (in nanoseconds) are shown below for Chronicle RingZero (first plot) and LMAX Disruptor Ring Buffer (second plot). Note the RingZero plot uses a linear latency axis, whereas a logarithmic scale is used for the LMAX Disruptor results.

The results show lower latencies across all percentiles with Chronicle RingZero compared to LMAX Disruptor. In addition, the outliers are better controlled and the sensitivity to message rate is much less with Chronicle RingZero.

For more details on the tests and the code used please contact info@chronicle.software

Want access to exclusive Chronicle content?

The Chronicle Community is now live, hit the button below and join the community, for free! You'll get exclusive access to blogs, guides and video content. Join today!

Want more from Chronicle? Subscribe today!

Something went wrong. Please check your entries and try again.