LmCast :: Stay tuned in

Scaling and benchmarking a critical message bus using a new indexing strategy

Recorded: Oct. 9, 2026, 1 a.m.

Original Summarized

Jane Street Blog - Scaling and benchmarking a critical message bus using a new indexing strategy

Home

All Posts

Machine Learning

Authors Index

Jane Street

Subscribe to email updates

Subscribe to Email Updates

Featured Reads

Read more

Using ASCII waveforms to test hardware designs

Read more

Finding memory leaks with Memtrace

Tags

async
book
c
camlp4
code-review
comments
compiler
core
hackerschool
hg
incremental
internship
interviewing
machine-learning
ocaml
parallel-programming
performance
ppx
real-world-ocaml
registers
speed
ui

Get the RSS feed

Jane Street Open Source

Join Our Team

Scaling and benchmarking a critical message bus using a new indexing strategy

Oct 05, 2026 |

10 min read

Share on Facebook

Share on Twitter

Share on LinkedIn

By: Nicholas Yang

The following is part of a series of posts about 2026 summer intern projects—for more,
see “What the interns have wrought, special jumbo 2026
edition”
Aria
is our internal messaging framework and hosted system that processes multiple terabytes of
data per day. Clients can subscribe to Aria to get a live stream of messages. As Aria
usage has rapidly grown at the firm, we’ve had to find more opportunities to optimize and
re-architect the system to scale with the increase in data volume and throughput. An
intern working with the Aria team, Theodor Totev, focused this summer on using indexing
and tree-splitting to improve a specific use case: How can we make it cheaper for clients
to read just a subset of messages? His optimizations led to a 30% decrease in CPU
usage when running on production workloads, while keeping the extremely high bar of
correctness needed for such a critical system.
Filtering messages was overloading our servers
When Aria delivers messages to a client via TCP, it keeps the recent stream, what we call
the stream tip, in an in-memory ring buffer. If a client falls behind, it can request
recent messages from this ring buffer to get up to date. We call this process tip
recovery.
One challenge with tip recovery is that Aria stores the entire stream of messages, when
clients often only care about a much smaller subset of the messages. Aria divides the
message stream into topics, which form a hierarchical namespace like a file
system. Clients can subscribe to an individual topic or to a topic subtree, which consists
of all topics under a given topic, similar to a
globstar. Aria
filters the entire stream down to only the messages from the subscribed topics and
delivers these messages to the client.
Originally we were fine doing this filtering as a simple linear pass because, while
algorithmically inefficient, looping over the stream is CPU cache friendly and therefore
decently fast. However, as the number of clients doing tip recovery grew, we noticed that
our servers were struggling with the increased load. Some servers reached 100% CPU
utilization, resulting in clients “falling off the tip” and being unable to catch up. We
added more servers as a temporary fix, but it became clear that we desperately needed to
re-think our tip recovery code.

Theodor decided to solve this problem by adding index data structures that Aria could use
to efficiently filter messages from the stream. But what should be indexed? A naive
approach would be to make an index for each topic. However, Aria instances can have almost
a million topics, making this approach untenable. Instead, Theodor created an index for
each topic partition. A topic partition consists of all topics with the same
two-segment prefix, a segment being a single part of the topic name separated by a
slash. For instance, app/codestore/commits and app/codestore/features would both be
under the app/codestore topic partition.
Each topic partition gets an index of its messages’ location in the Aria stream:

When a client requests messages, Aria does an n-way merge of the indexes using a
min-heap. This allows Aria to efficiently reconstruct the message stream, in order, for
just these specific topic partitions:

Prototyping and benchmarking the index
As with any performance work, we had to benchmark in order to validate that we were
actually improving the system. We also wanted extensive testing, since the message
publishing logic is in the critical path for Aria.
Theodor started by writing a tool to profile various recovery scenarios. That way, we
could test out different configurations, such as the number of topic partitions, the
degree of interleaving, the number of readers, etc., and see how changing these variables
affected the performance of the system.
With the benchmark in hand, he implemented the initial version of the topic partition
index. When we profiled this implementation, we found that the min-heap was the biggest
bottleneck in our code. Before AI, this is probably where we’d pick a single
implementation that appeared to be better. But these days, running experiments is cheap:
Theodor prompted an agent to spin up five different heap implementations and profile them
overnight. The next day, we had our answer: fast_heap_unboxed gave us a 2x performance
improvement to our indexed recovery code.
Theodor tested the new index with plenty of expect
tests, exercised the new logic in
Antithesis, and
finally had a swarm of agents analyze the code with high scrutiny.
Using a block pool to store the indexes
Once we devised the index data structure, we needed to figure out an efficient
representation. We didn’t want to make a ring buffer for each index, since ring buffers
are not really dynamically resizable. They would therefore have to be sized to accommodate
the worst case scenario. Specifically, index size is inversely proportional to message
size (smaller messages mean more messages can fit in the tip store, which means you need a
larger index). An Aria message can be as small as 32 bytes. If the entire tip store
consisted of messages that small, the corresponding index would be 2GB. Keeping a 2GB
index for each topic partition would waste too much memory.
Instead, we wanted an index to dynamically shrink and grow with the number of messages in
its topic partition.
What we settled on was using a shared pool of blocks that each contain 1024 entries. The
indexes point to a block and insert values into it. Once all of the messages within a
block have left the ring buffer, blocks can be popped off from the index and re-used for
other indexes:

Reading old messages was taking too long
Theodor’s work on indexing fixed our tip recovery woes, but we had another message
delivery problem: Clients that needed messages from before the stream tip were waiting
way too long.
When a client reboots, it often requests all messages since the beginning of the week from
its subscribed topics. We call this process initial recovery. Initial recovery can
involve millions, even billions of messages. It’s absolutely critical that Aria read
these messages and deliver them to clients as quickly as possible. Also, clients tend to
reboot all around the same time, so it’s especially important that this process scales
well.
In one particular incident, an initial recovery that usually took under 2.5 seconds was
taking over 13 minutes. When we dug into why, we found the same issue that plagued the
tip store: Aria was reading and filtering 10x more data than it actually needed to
send. It was clear that we needed to rethink how we were storing messages on disk.
Aria persists messages in subtree stores
Aria initially stores the messages on disk in chronological segments for each topic
partition. Then, a separate process takes these segments and splits them into multiple
subtree stores that each contain messages for a topic subtree. These subtree stores
are intended to strike a balance between writing to many files, which results in efficient
filtering but requires more work to recombine into a message stream, and writing to fewer
files, which is easier to recombine but less efficient to filter.
To do this splitting, Aria had been using a simple heuristic: it chose the subtree store
by reading the first three segments of the topic. So if we had topics
app/options/orders/created and app/options/orders/cancelled, those would both get put
into a subtree store for app/options/orders. If the topic had fewer than three segments,
it was put into its own subtree store; for instance, app/options would get its own
store. Effectively, this heuristic gave each direct child of a topic partition a separate
subtree store.
However, this heuristic didn’t work well when one topic in a store had significantly more
messages than the other. If the client were to subscribe to just the less active topic,
Aria would have to filter out all of the other topic’s messages. Like with tip recovery,
this filtering created a lot of work.
More broadly, we weren’t happy that users had to understand this specific aspect of Aria’s
internal design when designing their topic structure. We wanted users to structure their
topics in a way that made sense to them and have them trust that Aria would do the
splitting intelligently.
Theodor was tasked with developing an algorithm that could avoid this issue by
intelligently splitting the topic tree based on each topic’s message volume. Aria is able
to calculate the message volume per topic, since it does this segment processing step
after persisting the message stream.
Gathering data and testing different algorithms
Like with the tip recovery implementation, Theodor’s work on adaptive splitting required
exploring different options. He started by gathering data from various Aria sessions that
could be used to test out different algorithms. He then implemented a few different
algorithms for splitting and ran them on the collected data. Theodor analyzed these
results from a few different lenses, such as:

How many bytes do we have to ignore from a store if we read a topic?
What is the sum of these “wasted bytes” over all the topics?
What topic, if read, would result in the most wasted bytes?
What topic, if read, would result in the worst ratio of total bytes to useful bytes?

As before, this process of exploration was aided by LLMs. Theodor was able to quickly
vibe-code a web UI that visualized the different splitting algorithms across real data
sets.
The final algorithm
Eventually Theodor settled on a solution that combined a greedy clustering algorithm with
a binary search. This gave us the properties that we were looking for: Topics with a lot
of messages receive their own subtree store, while smaller topics are folded into a single
store.
Here’s an example of a topic tree using the previous heuristic:

Notice how the 2.72GB topic is in the same store as the 10MB and 28.5MB topics. This means
that if someone wants to read the 10MB topic, they have to filter out all those other
messages. Meanwhile, the smaller topics are split between three stores, even though
they’re orders of magnitude smaller than the large topics.
With the new adaptive splitting algorithm, this is how the same tree looks:

Now the 2.72GB topic has its own store separate from the 28.5MB and 10MB topics, while the
smaller topics are all bundled together into a shared store.
Using multiple testing strategies on the algorithm
Since the adaptive splitting directly affects how messages are stored in Aria, we wanted
to ensure with a high degree of certainty that there were no bugs. Dropping or re-ordering
a message would have serious consequences.
We started by using expect tests to check various properties of the algorithm, such as
large topics getting their own store, small siblings sharing stores, and so on.
For message consistency, we already had an existing property-based test that inserted a
sequence of randomly generated messages on randomly selected topics and then ran the
splitting algorithm. The test read out random pieces of the topic tree and confirmed that
the messages had the correct ordering and content. Theodor expanded the test to randomize
the tree splitting, which confirmed that message content stayed the same regardless of how
the topic tree was split.
Finally, we did multiple runs in Antithesis to confirm that the changes didn’t break
anything else in Aria.
How did the optimizations do?
The tip indexing code has been shipped to production. We’ve seen preliminary results in
our staging environment that showed 30% less CPU utilization in some real-world
scenarios. Overall latency across clients went down significantly during those
times. We’ve noticed some multi-second tail latencies in servers that didn’t implement the
indexing, while these issues didn’t appear in any servers running the new code.
Adaptive splitting is deployed to our staging environment and will be running in
production shortly.

Nicholas is a software engineer and technical writer at Jane Street. He has written
multiple blog posts about chili oil.

#internship

previous post
next post

Subscribe to Email Updates

Signals & Threads Podcast

Listen to the latest episode

Featured Tech Talk

The Algorithm for Precision Medicine

Jane Street YouTube Channel

Featured Reads

Read more

Using ASCII waveforms to test hardware designs

Read more

Finding memory leaks with Memtrace

Tags

async
book
c
camlp4
code-review
comments
compiler
core
hackerschool
hg
incremental
internship
interviewing
machine-learning
ocaml
parallel-programming
performance
ppx
real-world-ocaml
registers
speed
ui

RSS

Get the RSS feed

Jane Street Open Source

From committing patches to the Linux kernel to releasing our own projects, we’re always looking for ways to participate in the open source community.

Join Our Team

Where FP meets the real world.
If you're interested in working at a place where functional programming meets the real world, then apply for a job at Jane Street.
Learn more

Who We Are

What We Do

Client Offering

The Latest

Culture

Join Jane Street

Contact Us

Disclosures & Policies

© Copyright 2015-2026 Jane Street Group, LLC. All rights reserved. Services are provided in the U.S. by Jane Street Capital, LLC and Jane Street Execution Services, LLC, each of which is a SEC-registered broker dealer and member of FINRA (www.finra.org). Regulated activities are undertaken in Europe by Jane Street Financial Limited, an investment firm authorized and regulated by the U.K. Financial Conduct Authority, and Jane Street Netherlands B.V., an investment firm authorized and regulated by the Netherlands Authority for the Financial Markets (Autoriteit Financiële Markten), and in Hong Kong by Jane Street Hong Kong Limited, a regulated entity under the Hong Kong Securities and Futures Commission (CE No. BAL548). Each of these entities is a wholly owned subsidiary of Jane Street Group, LLC. This material is provided for informational purposes only and does not constitute an offer or solicitation for the purchase or sale of any security or other financial instrument. | Jane Street and the concentric circle mark are registered trademarks of Jane Street.

Privacy
Cookies

Jane Street Group, LLC uses cookies and similar technologies, including third-party cookies, on this Site to provide basic functionalities and perform analytics. You may accept or decline cookies by selecting “Accept” or “Reject”. For information regarding our cookie practices, see Jane Street’s
Ad and Cookie Policy.

Accept All
Reject All

The optimization of Jane Street's internal messaging framework, Aria, focused on scaling the system to handle increasing data volume and throughput by improving message filtering and delivery mechanisms. The initial challenge arose because the process of filtering messages for clients during tip recovery was overloading servers, leading to performance degradation and client delays. This situation was addressed by Nicholas Yang, who focused on implementing indexing and tree-splitting strategies to make reading subsets of messages more efficient.

Aria organizes messages into topics forming a hierarchical namespace. When clients subscribe to topics, Aria must filter the entire message stream to deliver only the relevant messages, which, while logically correct, proved computationally expensive, especially as the number of concurrent tip recovery requests grew. To mitigate this, the approach shifted from a simple linear pass to utilizing index data structures. Instead of indexing every topic individually, the solution involved indexing topic partitions, which group topics sharing a common two-segment prefix. Aria then efficiently reconstructs the message stream for requested topic partitions by performing an n-way merge of these indexes using a min-heap.

Benchmarking and implementation of this indexing system required thorough experimentation. Initial profiling identified the min-heap usage as a major bottleneck. Through experimentation facilitated by various agents, the team determined that a specialized implementation, fast_heap_unboxed, offered a twofold performance improvement for the indexed recovery code. Furthermore, to manage memory efficiently, the indexing structure utilized a shared pool of blocks, each containing fixed-size entries, allowing blocks to be dynamically reused once all messages within them had left the ring buffer.

A second major performance issue involved initial recovery, where clients requesting historical messages faced extreme latency because Aria was processing ten times more data than necessary. This necessitated rethinking how messages were persisted on disk. Aria stores messages in chronological segments and then splits these segments into subtree stores, intended to balance efficient filtering with manageable recombination effort. However, the initial heuristic used for splitting these segments, which relied on the first three topic segments, failed when message volumes varied significantly across topics, leading to unnecessary filtering across unrelated data.

To resolve this structural inefficiency, an adaptive splitting algorithm was developed. This algorithm intelligently splits the topic tree based on the relative message volume of each topic to ensure that topics with high message counts receive dedicated subtree stores, while smaller topics are grouped into shared stores. This adaptive method was refined through extensive data gathering and testing, aided by language models for visualization. The final approach combined a greedy clustering algorithm with a binary search to achieve this balanced splitting.

The algorithm was rigorously validated through multiple testing strategies. Expect tests were used to verify properties such as separating large topics into unique stores and maintaining message consistency through property-based tests that randomly randomized the message content and the resulting topic tree structure. The process also involved multiple runs in Antithesis to confirm system stability. Preliminary results demonstrated significant optimization, showing up to 30% reduction in CPU utilization in staging environments and marked latency improvements for clients, establishing the efficacy of the new indexing strategy for optimizing the critical message bus.