Skip to main content

Tuning Ember for Market Maker - Part 3

November 2026

  • work in progress -

Overview​

Part 2 of this series was written in February 2024. It covered a tuned-up AMI, CPU pinning with busy-spin idle strategies, TimeBase Topics for market data distribution, and latency monitoring. All of that still applies. This article does not replace part 2. It adds recommendations based on what we have learned since then:

  • Upgrade to Ember 1.16.2+. Ember now processes orders faster in OEMS, and the journal swapper no longer lets hot-path threads take page faults.
  • Upgrade to TimeBase 5.7+. It has significant throughput optimizations in the client socket layer and in storage.
  • Consider AMD-based instances. We are still researching them. If you use them, place communicating threads in the same CCD.
  • Be aware of CPU steal by the AWS hypervisor and its effect on tail latency.
  • Build an optimization harness for reproducible experiments that don't touch production.

We also start a reading list of external material that we found useful.

Disclaimers​

  • The recommendations in this article are made on top of the steps described in part 1 and part 2.
  • These instructions assume your system has sufficient CPU capacity. For example, you need to assign a dedicated physical CPU core to each tradeable exchange.
  • Version requirements:
    • Ember 1.16.2+
    • TimeBase 5.7+
  • We recommend discussing the applicability of these steps to your specific environment with the Deltix team.

Upgrade Ember to 1.16.2+​

Faster OEMS order processing​

Ember 1.15 redesigned the OEMS orders cache and the way order state is tracked. This doubled the maximum sustained order request throughput of a single Ember instance. A matching engine scenario now runs at around 400-450K order messages per second before showing signs of high load. See Matching Engine Order Throughput for how we measured it.

A market maker rarely sends orders at such rates. The same change also shortens the order processing path that every request goes through, so it helps tick-to-order latency as well. Deployments still on the 1.14 line don't have this optimization.

Journal swapper keeps journal pages writable​

The journal swapper pre-allocates and pre-touches each new journal segment, so that hot-path threads (algorithms, connectors, trade engine) never take a page fault when they write to the journal. We found that this pre-touch doesn't last (#2453):

  • Pre-touching a page leaves it dirty and writable.
  • Linux writeback flushes dirty pages of a file-backed mapping roughly every 5 to 35 seconds (vm.dirty_expire_centisecs = 30 s by default). Once a page is flushed, the kernel write-protects it again so that it can detect the next write.
  • With the default journal layout, the swapper prepares a segment about 48 MB ahead of the writers. At benchmark write rates (tens of MB/s), writers reach the prepared segment within about a second, while the pre-touch is still in effect. At typical production rates (tens of KB/s), writers reach it after many minutes, long after the pages were flushed.

As a result, at low write rates the first write into every 4 KB journal page traps into the kernel on the writer's thread. In one production capture, every journal page written during a 15-minute window caused a write fault, and the fault rate matched the jump between the P90 and P99 latency of order replace requests.

High-rate benchmarks don't show this problem. That is exactly the kind of issue that only a controlled experiment at realistic rates can find (see the optimization harness section below).

Starting with Ember 1.16.2, the journal swapper also periodically touches the pages just ahead of the writers' current position, so writers find them writable regardless of the write rate. The cost at high write rates is negligible.

tip

Other memory-mapped files on the hot path have the same re-fault behavior. Keep the Aeron directory on /dev/shm (with enough --shm-size when running in Docker).

Upgrade notes​

Ember 1.16 is a major release. Before you upgrade, review the release notes and plan for the following:

  • The journal format has changed. Run the journal upgrader before you start the new version.
  • Java 21 is now the default runtime. Java 17 is still supported.
  • The algorithm API has changed (MarketSubscription and SimpleMarketDataProcessor). You may need to update and rebuild custom algorithms.

Upgrade TimeBase to 5.7+​

TimeBase 5.7 has a series of performance optimizations that matter for market data distribution:

  • Client socket layer. The TimeBase socket server has been reworked, and polling of live data readers is faster. Together these raise the throughput between TimeBase and its clients (Aggregator, Ember, TimeBase Topics clients).
  • Storage. Write queue and file preallocation are faster, and LZ4 compression uses a faster reset implementation.
  • Codecs. Encoding and decoding of timestamps and of nullable fields is faster, and the instrument lookup path no longer allocates memory.

TimeBase Topics, which we recommended in part 2 for the latency-critical market data path, are still the recommended option. The TimeBase 5.7 improvements mostly help the stream paths: market data recording, connectors that still use streams, and the "carbon copy" streams that back each topic.

AMD-based instances (under research)​

Part 2 was based on Intel instances (c6id family). We are now evaluating AMD EPYC-based instances on AWS, for example the c7a and c8a families.

If you consider them, note one difference that affects the CPU isolation and pinning setup from part 2. On these instance families each vCPU is a full physical core, with no hyper-threading. There are no hyper-threading siblings to isolate together with each critical core. Count the cores you need for critical threads accordingly, and review your isolcpus and affinity settings rather than copying them from an Intel setup.

For AMD's own tuning recommendations, see Low Latency Tuning for AMD EPYC 9005 CPU Powered Servers.

Our research is not complete. The first result, on thread placement across CCDs, is described below. We will update this section as more experiments finish. If you plan to move to AMD instances, contact the Deltix team first.

Keep communicating threads in one CCD​

AMD EPYC processors are built from several chiplets (CCDs), and each CCD has its own L3 cache. It works like NUMA for the L3 cache: cores in the same CCD share an L3, and cores in different CCDs don't. On an m8azn.12xlarge instance (48 vCPUs from 8 CCDs, 6 cores per CCD) we measured a one-way cache line handoff between two busy-polling threads at 41-50 ns inside a CCD and 217-260 ns across CCDs, about 5.5 times more. Ember's critical threads pass messages to each other through busy-polled in-memory queues, so every handoff that crosses a CCD boundary adds latency. Each message moves several cache lines (the payload and the queue indices), so the penalty is larger than a single handoff.

We measured the effect on the FIX order entry path (wire-to-wire latency at about 26K requests/s, four fresh instances, taskset used to re-pin threads on the same instance between phases). Moving the FIX gateway transport thread (trade-gwy-trans-*) into the same CCD as the session thread (trade-gwy-sess-*) reduced average latency by about 1.3 µs (from 9.1-9.8 µs to 7.9-8.5 µs, or 13-15%). The median improved by 1-2 µs and p99 by 1-3 µs. p99.9 did not change. The gain was the same on all four instances. Placement of the trade engine and algorithm threads within the same CCD made no measurable difference, so the transport and session pair is the one to get right.

To apply this, find the L3 groups with lscpu -e=CPU,CACHE (or read /sys/devices/system/cpu/cpuN/cache/index3/shared_cpu_list), and pin threads that exchange messages in your critical flow within one group. The topology that AWS guests report matches the measurements, so it can be trusted for pinning. This doesn't apply to Intel instances like c6id, where all cores of a socket share one L3. See CPU Affinity for how to configure thread affinity.

CPU steal on AWS Nitro instances​

Isolated cores don't protect you from the hypervisor. From time to time, AWS Nitro takes a vCPU away from the guest for its own work (Linux reports this as steal time). Inside the guest a stolen vCPU simply stops: there's no context switch, no interrupt and no JVM pause. If an Ember critical thread runs on that vCPU, all orders that pass through it wait.

On whole-host instance sizes (we tested c6id.32xlarge and c8id.48xlarge) we found that once a minute the hypervisor stops one physical core for 22-30 ms. When that core ran the FIX gateway session thread, p99.99 latency was 16 ms instead of 127 µs. On smaller, shared sizes, like the c6id.12xlarge we use for benchmarks, we haven't seen this pattern, but the host is shared with other workloads, and steal is a likely contributor to the run-to-run variation of the extreme tail (p99.9 and above) in our published results. We made a small project that reproduces the effect on a stock Amazon Linux AMI, without Ember: aws-nitro-cpu-steal.

In practice: avoid whole-host sizes for latency-critical deployments, monitor steal on the cores that run critical threads (mpstat -P ALL 1, the %steal column), and repeat benchmark runs on fresh instances before you draw conclusions about tail latency.

Optimization harness​

Tuning steps like the ones in this series must be checked by measurement. A change that helps on one instance type, kernel or load profile can hurt on another, and some problems (like the journal page faults above) only appear under specific conditions. Production is the wrong place for these experiments: the load isn't repeatable, the environment is noisy, and every experiment puts real trading at risk.

We recommend building an optimization harness, a test environment that you can recreate from scratch and run the same experiment in repeatedly. It should:

  • Provision the infrastructure from code, so that each run starts from an identical environment: instance types, AMI, network and storage.
  • Deploy the exact versions of Ember, TimeBase and your algorithms under test, with configuration kept under version control.
  • Generate a realistic and controllable load: market data rates, number of client connections, order rates, and warm-up periods.
  • Collect latency histograms and system metrics and archive them with the details of each run (versions, settings, a comment), so you can compare runs over time.
  • Tear down the environment when the run is complete, to control cost.

Our approach: Terraform + Ansible​

We use this approach for Ember's own latency and throughput tests. For example, the Matching Engine Order Throughput results were produced with it.

  • Terraform provisions the test infrastructure on AWS: VPC, security groups, an Ember server instance (on a tuned AMI built with ember-ami-builder) and one or more client instances.
  • Ansible configures the hosts, deploys TimeBase, Ember and the latency tools, starts FIX client bots on the client hosts, and collects the results. Each run is archived to S3 and a summary is posted to a team channel.
  • A single script, driven by environment variables, controls each run. The variables select:
    • the Ember version or a custom build
    • the server OS (Amazon Linux 2023, Rocky Linux)
    • the number of client hosts, connections per host and order rate per connection
    • the warm-up and capture periods, and the number of rounds
    • optional diagnostics: network traffic capture, per-request latency plots, JVM page fault tracing, and perf probes

Some practical advice for running experiments:

  • Change one variable at a time, and run several rounds of each configuration. A single run is not a result.
  • Always include a warm-up period before you capture measurements (JIT compilation, page cache, connection setup).
  • Test at your production rates, not just at maximum rates. Some effects only appear at low rates.
  • Record everything that defines a run: software versions, instance type, AMI, kernel parameters, and Ember configuration.

We can share this harness with clients on request. Contact the Deltix team if you are interested.

Reading list​

External material that we found useful when we worked on latency:

Related articles on this site: