System Architecture (L2 Market Data Gateway)
Hyperliquid → C++ gateway → Node relay → Next.js viewer
Hyperliquid
source · external
rdtscp stamp · never blocks, never waits on I/OL2DataCapture
capture · normalise · build book
l2-gateway-relay
fan-out & aggregation
Web viewer
subscribe · decode · render
Browser
sink · trader
Capture sink
written by the gateway · terminal, not a source
- ticks.binMemory-mapped, 64 B packed NormalizedTick records, 10M pre-allocatedMmapWriter
- latency.csvPer-stage samples: queue, parse, book_update, publish (ns)LatencyStore
- session_<ms>.ndjson.gzgzip NDJSON of every export record, same schema as the live streamColdPathExporter
Nothing reads these back at runtime — the relay is fed only by the live /ingest socket, so capture can stall or be deleted without touching the live path.
Latency Timeline
The chip is that sample crossing the gateway, handed on at each stamp — taking the colour and name of the phase it entered. Every ring flashes as rdtscp is read; each bar stays filled until the journey restarts.
simdjson reads the frame in wire order and parse_scaled turns prices and sizes into fixed-point int64.
The tick sits in the lock-free SPSC ring until the consumer thread picks it up. This is the stage that grows first under load.
apply_depth writes the level into the 2M-slot book and refreshes the coarse {4,3,2} tiers.
The record is handed to the relay push ring and to the capture writers. The hot path is done here.