Prediction-Market Book Freshness from Wire to Parser
The freshness of a consolidated prediction-market book depends on two things: where each byte originates and how long that byte takes to process once it lands. Distance sets the first and no software repeals it. Parser and decimal arithmetic set the second and are engineering. This post measures both on Kalshi and Polymarket: a network probe from two continents and a twelve-entrant ingest race across seven languages that all reconstruct the identical book.
Start with the second question because it renders as motion. Each lane below is one of nine entrants: a language at its idiomatic best or a hand-tuned build of it. Its speed is that entrant's ingest throughput on the shared corpus. A faster entrant is a faster ball. Toggle the market to re-set every speed to the numbers measured on that venue's wire format.
C and tuned Rust streak across their lanes while Java barely moves. First the wire.
1. Pipeline and fingerprint check
A single update travels a fixed sequence of stages. A matching engine emits an event; it serialises to JSON, JavaScript Object Notation; it crosses a WebSocket secured by TLS, Transport Layer Security, through a content-delivery edge; it lands in the client kernel; userspace reads the WebSocket framing, parses the JSON, applies the delta to a book, and folds the book into a fingerprint. The diagram below runs one packet through that path. Toggle the venue and the propagate leg re-times itself to the measured wire latency, and the readout swaps to that venue's numbers.
One property of the parse stage runs through the whole post: it reads bytes that arrive from outside over a socket an external venue controls. Whatever language runs there runs on untrusted input. Direction removes one step on that path: the WebSocket specification, RFC 6455 in the Internet Engineering Task Force's Request for Comments series, requires a client to mask what it sends and forbids a server from masking what it sends. A market-data consumer therefore unmasks nothing on its receive path. Section 4 returns to the parse when the language is memory-unsafe.
The fingerprint is the correctness check. Across all books, let be the count of price levels, the sum of resting quantity and the sum of notional,
with prices and quantities stored as exact integers on a fixed scale. The triple is the correctness check: every entrant in every language must reproduce it bit for bit before its throughput counts. A parser that drops a level or rounds a price fails the check and is disqualified. Every number in this post clears that check first.
2. Origin of the bytes
2.1. Probes from two continents
Two probes ran from a residential connection in Kuwait and from a throwaway instance in Amazon Web Services (AWS) region us-east-1 within the same minute. A bare connect over TCP (the Transmission Control Protocol) to port 443 needs no authentication and terminates wherever the socket terminates. A WebSocket ping, timed to its pong, is a round-trip immune to clock skew. Both ran against Kalshi and Polymarket.

2.2. Edge handshake and distant origin
Kalshi sits behind a CloudFront edge in Ashburn and answers from an origin in us-east. A bare connect takes 1.38 ms (median) in region and its public status endpoint returns a first byte at 21 ms on a fresh connection. A rerun on 8 October 2026 timed the request alone on an open connection at 5–6 ms median from us-east-1 and us-east-2. Kalshi is native to us-east, engine and all.
Polymarket reads differently. TLS terminates at a Cloudflare edge close to every client (TCP connect in 1.4 ms from us-east and 2.4 ms from Kuwait) yet the WebSocket ping travels end to end and returns at 87.6 ms from us-east and 91.8 ms from Kuwait. The two values differ by 4 ms although the two vantage points sit 76 ms of round trip apart from Ashburn (Kalshi connect: 77.3 ms from Kuwait, 1.38 ms from us-east-1). The tight distribution reads as fixed propagation.

A second measurement agrees from a separate protocol. The order-book REST endpoint returns its first byte at 114 ms on a fresh connection. TCP connect and TLS to the edge take 6.5 ms of that (1.41 ms and 5.07 ms). The remaining 107 ms or so is the request travelling past the Ashburn edge to the origin and back. The 8 October rerun found warm requests to the same host at 96–109 ms median across four clients. An origin roughly equidistant from Ashburn and Kuwait sits in the European region and lies an ocean away from us-east. The same rerun pinged the WebSocket from AWS eu-west-2 (London) at 7–9 ms median.

A consolidated book's Polymarket leg is floored near 44 ms one-way from anywhere in the United States. Colocation gives single-digit legs to a us-east-native venue and nothing against a venue whose origin lies across the Atlantic.
3. Parse time per frame
3.1. Method
Twelve entrants (tuned variants included) in seven languages each reconstruct the same corpus of two million book deltas. Every entrant ran alone on a core-pinned c7i.large, best of seven, with the page cache dropped before each run and stray processes swept after. The seven languages are C, C++, Rust, Go, Java, JavaScript on Node and Python on CPython and PyPy. Every entrant produced the identical fingerprint. The throughput numbers therefore stand on equal correctness.

3.2. Two orders across languages
On Polymarket parse time per frame spans nearly two orders of magnitude, from 358 ns to 23.6 microseconds. The gap follows parser strategy first and language second. It is also a safety split: C and tuned C++ have no bounds or aliasing checks and are therefore memory-unsafe, while the tuned Rust matches their class with both.


PyPy gains almost nothing over CPython because the hot path is Decimal arithmetic and a C-level parser and a tracing just-in-time compiler (JIT) accelerates neither. orjson lifts CPython above Go and both stdlib variants. Node's V8 leads the managed runtimes. Java through Gson and BigDecimal is the outlier. Object churn and boxed decimals drag it down and a fixed-integer rewrite would lift it as it lifts every other language.
Wire format moves these numbers as much as language does. Kalshi ships each delta as one signed increment. Polymarket ships a full ladder as an absolute-size set. So Java, whose time goes to boxed-decimal churn, runs seventeen times faster on Kalshi than on Polymarket (1.4 microseconds against 23.6) and the Python entrants re-rank between the venues. Toggle the market on the first figure to watch the field reorder.
3.3. Measurement quality

4. Both axes together
Wire and core are two segments of one path, and they live in different regimes.

Geography fixes wire time at milliseconds and the parser fixes per-frame time at nanoseconds. The edge terminates TLS close to every client and hides the handshake and never the tunnel back to a distant origin. The interactive byte path at the top traces one packet at a time.
A broker folding many venues incurs the worst wire leg once and the per-frame time on every update of every market. At 358 ns a core absorbs 2.8 million frames a second. At 764 ns idiomatic Rust absorbs 1.3 million. Those figures count parse and apply. The framing layer sits ahead of them at a further tens of nanoseconds a frame in a compiled runtime. Read the throughput as a ceiling on the core. Six of the entrants (Node, Go, Java and the three Python builds) run under a garbage collector and are exposed to collection pauses that the compiled non-collected entrants do not have. The race reports best and median per run and leaves those pauses unmeasured. When the wire already takes 44 ms to reach a venue across the Atlantic a garbage-collection pause added at the core is the one avoidable latency on the whole path.
Memory safety is the second half of the case, and it turns on the same hot path.
4.1. Memory safety at the trust boundary
The parse stage sits where untrusted bytes meet a privileged process. The wire arrives over a socket that a compromised feed, an intermediary or a market maker shaping frames can influence, and the book it builds drives order entry. A memory fault in that parser is a security exposure as well as a reliability one.
The faults have names and each fits this workload. A truncated or malformed frame can walk a C parser past the end of its input and read adjacent memory. An attacker-sized level count can write past a book buffer and corrupt the heap. A price scaled to an integer can overflow and wrap and so corrupt a control total. A book that grows and reallocates can leave a live pointer to a freed level.

Each fault has a worst case. The mild one is a crash: the ingest dies mid-session, the book freezes, and downstream quotes run off stale prices at the moment a volatility spike lifts the message rate that triggered the fault. The worse one is silent corruption: no crash, a wrong book and a strategy trading a phantom price with real money, caught only when the fingerprint happens to diverge. The worst is remote code execution: a buffer overflow driven by attacker-shaped wire hands whoever shaped the bytes control of the trading process and its credentials and order entry.
The map above sorts every entrant by two properties: whether a collector runs and whether the language is memory-safe. Three corners are occupied. C and C++ sit in the unsafe collector-free corner: fast and exposed. Go, Node, Java, the Python interpreters and Fil-C sit in the safe collected corner: out of danger and subject to the pause. The safe collector-free corner is the one the hot path wants and Rust occupies it. The fourth corner (unsafe and collected) stays empty because nobody adds a collector and keeps the unsafety.
4.2. Retrofitted safety and native safety
C and C++ can be made memory-safe after the fact. Fil-C compiles unmodified C and C++ and enforces pointer safety at run time with a concurrent garbage collector. Running the identical nlohmann parser through it, against the clang -O2 build of the same source, measures the overhead of the guarantee.

On Kalshi the safe build takes 11,852 ns a frame against 2,707 ns for the unsafe one, 4.4 times slower. On Polymarket with its heavier ladders it takes 19,775 ns against 4,097 ns, 4.8 times slower. Fil-C shows that the safety is reachable from C++: a parser made memory-safe at run time runs almost five times slower.
The hand-tuned Rust is the other end of that measurement. It reaches 359 ns a frame on Polymarket and 276 ns on Kalshi, in the same tier as C with no unsafe block anywhere in its source. The tuning that took Rust to C-class throughput kept all of the safety. C and C++ reach that speed by staying in the unsafe corner. Fil-C leaves the corner at a four to five-fold slowdown. Rust was never in it. Throughput next to C and safety without a collector: that is the case for writing the hot ingest in Rust.
5. Provenance
Measured 18 August 2026. The network probe is pure-stdlib TCP-connect and WebSocket ping/pong, the latter immune to clock skew, run from Kuwait and from AWS us-east-1. Kalshi sits behind CloudFront in Ashburn. Polymarket sits behind Cloudflare with its edge in Ashburn and its origin in the European region. The compute race ran on a us-east-1 c7i.large, one core pinned, page cache dropped before each run, best of seven, over deterministic corpora of two million deltas built from a fixed seed. Every entrant produced the identical fingerprint before its number counted. All hosts and credentials were torn down after measurement.