Exchange Collections is an open source high-performance Java collections library, extracted from the exchange-core matching engine.
All collections are primitive-specialized (long keys, long or object values), allocation-conscious
and designed for low-latency, single-threaded hot paths.
| Module | Artifact | Contents | Docs |
|---|---|---|---|
collections-core |
collections-core |
Adaptive Radix Tree, hashtables (long-long, tuples, snapshots), record store, queues (indexed FIFO, events, reorder window), price ladder, time windows and series, objects pool | Collections |
collections-orderbook |
collections-orderbook |
Order book implementation built on top of the core collections | Order book |
collections-ledger |
collections-ledger |
Balances (available, reserved) with checked postings and batches | Balances |
collections-affinity |
collections-affinity |
Pinning threads to CPU cores, NUMA topology and memory placement checks, no dependencies | Thread affinity |
tests-perf |
– | Latency / throughput benchmarks (not published) | Benchmarks |
tests-stress |
– | Long-running randomized stress tests (not published) | Testing |
- To use the published artifacts:
collections-coreandcollections-orderbook0.6.0 need Java 26+; their next release, 0.8.0, drops the published bytecode level to Java 21.collections-affinity(0.7.0) needs Java 22+, as it uses the Foreign Function and Memory API. - To build from source: JDK 26 and Maven 3.9+ — the benchmark and stress modules use newer language APIs than the published ones.
Add the dependency to your pom.xml:
<dependency>
<groupId>exchange.core2</groupId>
<artifactId>collections-core</artifactId>
<version>0.6.0</version>
</dependency>And, if you need the order book:
<dependency>
<groupId>exchange.core2</groupId>
<artifactId>collections-orderbook</artifactId>
<version>0.6.0</version>
</dependency>For pinning threads to cores (Java 22+, no dependencies, see Thread affinity):
<dependency>
<groupId>exchange.core2</groupId>
<artifactId>collections-affinity</artifactId>
<version>0.7.0</version>
</dependency>The modules share one version line, but 0.7.0 is collections-affinity alone: there is no collections-core
0.7.0. The balances (collections-ledger) come with 0.8.0.
To build from source and install into the local repository:
mvn clean install| Class | Use for | Type | Keys → values | Status |
|---|---|---|---|---|
LongAdaptiveRadixTreeMap |
a sorted map: price levels, stop orders, top-N walks | Adaptive Radix Tree (ART) | long → object |
stable |
LongLongHashtable |
long → long lookups: ids, handles, counters |
open-addressing hashtable | long → long |
stable |
LongLongLL2Hashtable |
the same, where a resize must not pause the thread | hashtable, async resizing | long → long |
stable |
RecordStore |
several fields of one thing, reached by a handle kept elsewhere | paged records by handle | handle → long fields |
new |
LongRecordTable |
records under keys, handles that stay valid | hashtable index + records | long → long fields |
new |
LongTupleHashtable |
keys of several longs: (account, currency), a UUID | open-addressing hashtable | longs → longs, fixed widths |
new |
LongSnapshotRecordTable |
records serialized as of a sequence while the writer goes on | sharded hashtable with snapshots | long → long fields |
new |
LongIndexedFifoQueues |
the orders of price levels, cancelled by order ID | FIFO queues, one ID index | queue key, entry ID, value: long |
new |
LongIndexedEventQueue |
timers and replay events, cancelled by ID | stable four-way min-heap with ID index | event ID, time: long; priority: int |
new |
LongSequenceBuffer |
a feed in sequence order: duplicates dropped, gaps found | reorder window by sequence | sequence → long |
new |
LongPriceLadder |
volume up to a price, the tick and the cost of a quantity | Fenwick tree over ticks | tick → volume | new |
LongRollingWindow |
rate limits, sums over the last span of time | ring of timed deltas | time, delta: long |
new |
LongTimeSeries |
backtests: as-of lookups, several series replayed in time order | append-only time series | time → long |
new |
ObjectsPool |
objects used again instead of allocated: ART nodes, orders | object pool | – | stable |
- Adaptive Radix Tree —
LongAdaptiveRadixTreeMap,ObjectsPool - Hashtables —
LongLongHashtable,LongLongLL2Hashtableand itsMigrationService - Records —
RecordStore,LongRecordTable,LongTupleHashtable,LongSnapshotRecordTable - Queues —
LongIndexedFifoQueues,LongIndexedEventQueue,LongSequenceBuffer - Price ladder and time windows —
LongPriceLadder,LongRollingWindow,LongTimeSeries - Thread affinity —
collections-affinity: pinning threads, NUMA - Order book —
collections-orderbook - Balances —
collections-ledger - Benchmarks — the machine and the settings behind the numbers, how to run them
- Building, testing, contributing
- Release notes
A collection's section: an example, the features, the cost of the operations, measurements and notes.