Engine architecture and benchmarks
A Rust service that turns Hyperliquid's feeds into decisions in microseconds, and the measured numbers behind that claim.
The hot path
One task owns the whole pipeline, so the hot path takes no locks: frame in, decisions out. Everything else (the API, the keeper, the cross-check, the Kinetiq rate reader) talks to it through channels and reads a snapshot it publishes four times a second. Built on tokio, tokio-tungstenite, axum and alloy; frames are parsed with sonic-rs into borrowed views, never copied.
Dependency and threshold index
Each condition is split into atoms (single comparisons) joined by a small boolean formula. Atoms of the shape value op constant and value crosses constant sit in a per-value index sorted by threshold. When HYPE's mid moves from old to new, only the atoms whose threshold lies between the two can change, and only those are touched. Other comparisons (like mark minus oracle over oracle) re-run in the VM whenever one of their values changes.
A strategy is re-evaluated only when one of its atoms changed state, a for timer came due, or a cross pulse ended. Identical atoms across strategies are stored once.
One set of semantics
- An event is one market update: a batch of values at one time.
- A strategy is false whenever any of its atoms errors (an unknown value, a math error).
crossesis true only in the event where the value moved across the threshold.for Dholds once the inner condition has been true since s and the event time, rounded up to the second, is at least s plus D.- A decision is a rising edge of the value: at most one per trigger.
How it is tested
| Test | What it proves |
|---|---|
| Reference interpreter + property test | A slow interpreter that walks the syntax tree and re-evaluates every strategy on every event shares nothing with the engine but the arithmetic. 3,000 random cases of random strategies and market sequences must give exactly the same decisions, and every decision must pass the on-chain VM with the values a keeper would submit. |
| Replay of recorded mainnet sessions | A WebSocket session captured from the live Hyperliquid feed: every frame parses, the engine is deterministic, and it agrees with the reference interpreter on real market data. |
| Shared VM vectors | One vector file runs through the Rust VM and the Solidity VM; both must produce the same result for every case. |
| Foundry suites | Unit, fuzz and invariant tests for the registry, limits, bonding and slashing, plus mainnet fork tests. |
Measured numbers
Every number below is copied from the published benchmark file, unchanged.
Measured 2026-11-29. one CPU core, release build (cargo --release), x86-64 Linux.
Criterion
| Bench | Median | What it measures |
|---|---|---|
parse/activeAssetCtx | 819 ns | parse one live activeAssetCtx frame |
parse/allMids | 224.99 µs | parse one live allMids frame (every listed market, about 25 KB) |
update/1000 | 48 ns | one HYPE mid move of 0.01% against 1,000 loaded strategies |
update/10000 | 125 ns | same, 10,000 strategies |
update/100000 | 1.003 µs | same, 100,000 strategies |
frame/10000 | 28.305 µs | a full HYPE activeAssetCtx frame (mark, mid, oracle, funding, oi) parsed and evaluated, 10,000 strategies |
frame/100000 | 1.604 ms | same, 100,000 strategies; the 10% general expressions on HYPE rerun on every mark move |
Replay loadtest
| Strategies | Frames | p50 | p90 | p99 | max | Frames/s |
|---|---|---|---|---|---|---|
| 10,000 | 10,480 | 1.7 µs | 11.18 µs | 250.1 µs | 720.81 µs | 127,718 |
| 100,000 | 10,480 | 2.08 µs | 180.14 µs | 873.91 µs | 11590.29 µs | 17,455 |
| Strategies | Channel | Frames | p50 | p99 |
|---|---|---|---|---|
| 10,000 | activeAssetCtx | 5,280 | 1.78 µs | 30.73 µs |
| 10,000 | allMids | 140 | 251.41 µs | 380.56 µs |
| 10,000 | l2Book | 160 | 7.49 µs | 9.67 µs |
| 10,000 | other | 280 | 0.26 µs | 3.77 µs |
| 10,000 | trades | 4,300 | 1.52 µs | 33.8 µs |
| 10,000 | userFills | 320 | 2.1 µs | 27.64 µs |
| 100,000 | activeAssetCtx | 5,280 | 2.2 µs | 947.22 µs |
| 100,000 | allMids | 140 | 300.44 µs | 425.08 µs |
| 100,000 | l2Book | 160 | 10.42 µs | 14.72 µs |
| 100,000 | other | 280 | 0.3 µs | 7.4 µs |
| 100,000 | trades | 4,300 | 1.6 µs | 34.12 µs |
| 100,000 | userFills | 320 | 3.49 µs | 29.91 µs |
With stocks: the larger universe
573 perps loaded: Hyperliquid core plus every HIP-3 dex (178 live markets on xyz, para, io, mkts; 128 tracking a US listing). fixtures/session-2.jsonl: 1,016 frames recorded from wss://api.hyperliquid.xyz/ws on Sunday 2026-11-29 with the US market closed: core allMids, allMids of each HIP-3 dex, activeAssetCtx and trades of HYPE, BTC, ETH, xyz:NVDA, xyz:TSLA, xyz:AAPL, xyz:SP500, xyz:GOLD, l2Book of HYPE and xyz:NVDA.
| Replay | Strategies | Frames | p50 | p90 | p99 | Frames/s |
|---|---|---|---|---|---|---|
| stocks session | 10,000 | 20,320 | 1.62 µs | 8.538 µs | 64.101 µs | 20,328 |
| stocks session | 100,000 | 20,320 | 1.939 µs | 53.674 µs | 1571.762 µs | 3,379 |
| original session, same moment | 10,000 | 10,480 | 1.821 µs | 14.472 µs | 298.836 µs | 24,199 |
| original session, same moment | 100,000 | 10,480 | 2.876 µs | 471.45 µs | 4986.735 µs | 2,987 |
Same core, release build, but the machine was shared with other builds at the time (load average about 30), so the tail is noisier than the quiet-machine table above. The original session was rerun at the same moment for a fair comparison. Command: scriptcore-engine loadtest N 20 fixtures/session-2.jsonl.
Method
Criterion benches (cargo bench --bench engine) for the evaluator alone; the loadtest (scriptcore-engine loadtest N 20) replays a recorded mainnet WebSocket session (524 frames captured from wss://api.hyperliquid.xyz/ws: activeAssetCtx, trades, l2Book, allMids, userFills) 20 times through the same parse -> state -> evaluator path the service runs, with N strategies loaded around the session's own HYPE price: 55% thresholds, 20% crosses, 15% threshold and funding, 10% general expressions (mark minus oracle). Latency is per frame, from frame text to decisions.
strategyChecksPerSec: frames per second times strategies loaded: every frame answers the condition of every loaded strategy, most of them through the index without runningatomsEvaluatedPerSec: comparisons actually re-evaluated per second
Reproduce them
The engine's criterion suite and the replay loadtest are the same code that produced the tables above.
cargo bench --bench engine # parse, update/N, frame/N scriptcore-engine loadtest 100000 20 # replay the recorded session 20 times, 100,000 strategies scriptcore-engine loadtest 100000 20 fixtures/session-2.jsonl # same, the session with HIP-3 stocks and every dex cargo test --release # property test, replay, shared vectors
Live metrics
The running engine reports its own live p50 and p99 from frame read off the socket to decision at /api/engine/stats, and a Prometheus page at /api/engine/metrics with frames by channel, decisions, fires sent, failed and refused, RPC errors by chain, WebSocket lag and reconnects, queue depth, strategies and atoms loaded, the cross-check gap, and the ingest-to-decision histogram.