Repository navigation
Spec 05 Engine
Source: spec/05-engine.md at commit a9f0d61. The file is the source of truth; this page is a summary.
Chapter 05 covers one book on one sequencer box. It first defines a sequential specification: apply every op in a linear order L, and every New matches on entry. The vyrn-vx-oracle implements this. The chapter then specifies a parallel engine that produces L: 49 lane cores, two cut cores, one BBO core, and the TX and order-stream cores. It gives byte layouts and the one writer core for every shared cache line. It gives each core's algorithm with its budgets, a proof that the parallel engine equals the sequential specification, and rules for replay, fairness, book parameters and in-box failures. LAT_MAX_NS is a maximum for every accepted packet. Work that cannot be bounded is either shed before it is accepted or split into bounded steps.
-
One reference semantics (§0 D1, §2).
Rescan,DepletionandIdlesteps are no-ops in the sequential specification. Everything else is an optimization that must not change the result. -
Linear order L (§0 D2, §3). Lane ops are ordered by the first step whose cut includes them, then by the priority key
(prio_ts, rank_e(lane), lane_seq). A forwarded op and its in-packet dependencies sit at the op's own step. -
Clamped step cut (§0 D3, §3.3). A step uses the two newest half-cuts, clamped below each lane's oldest unexecuted dependency. The source lane is also clamped at
q. -
Immutable queue positions in
Segment16FIFOs (§0 D4, §4.6). Positions are assigned in pass 1, in key order, and never move (INV-ENG-7). -
Copy-on-write slots (§0 D5, §4.3–§4.4). Each lane-written field that the BBO core reads is written once, or is a mask bit stamped by a
LaneSeq(INV-ENG-2). -
Safe-direction bounds (§0 D6, §9.5). The BBO core keeps
B ≥the true best bid andA ≤the true best ask. Cancels only widen the spread, so the bounds stay valid without the BBO core seeing cancels. -
Crossing lemma and
Rescan(§0 D7, §8.6, §9.4). An empty price band proves that a batch cannot cross. A non-empty band triggers an exact, boundedRescan. -
Routing (§0 D8, §6.5). IOC and FOK are always forwarded. Post-only is forwarded when it crosses the snapshot. The snapshot is only a routing hint (
INV-ENG-1). -
Settlement at the cut (§0 D9, §7.6). A lane settles a local op at the first boundary with
t ≤ C_f[lane], so settlement can be replayed. - Two-pass lane (§0 D13, §6.4). Pass 1 validates, reserves and classifies each message, and pushes each forwarded op with its dependency list. Pass 2 applies the independent joins and cancels.
-
Bounded steps (§0 D14, §8.5, §8.8). A step covers at most one level or
ENG_STEP_FILLSfills, then the sweep continues in the next step. An uncross runs in chunks under a freeze. -
Deadline admission (§0 D11, §6.8). The lane answers
Reject BUSYat dequeue or at the commit point. The BBO core emitsShedsteps. Both are logged, and replay never reads a clock (§10). -
Lane classes (§0 D15, §6.9). Lanes 0–41 are dedicated, one firm each. Lanes 42–48 form a 7-core pool on CCD 7, with per-account tokens, stealing, and logged
AcctTakerecords (Lemma 6.1). -
A stalled lane fail-stops (§0 D12, §14.1). A lane silent for
ENG_LANE_DEAD_NSfail-stops the sequencer. Spare cores take lanes only through a cooperative handover.
All values are budgets unless the spec marks them otherwise. None of them is a measurement.
| Quantity | Value | § | Kind |
|---|---|---|---|
LAT_MAX_NS (from 01 §5) |
1000 ns | §0 preamble, §11.1 | hard maximum |
| Cross fill, message index 9 | 880 ns (835 at index 0) | §11.1 | budget |
| Join or cancel ack, index 9 of 10 | 955 ns typical, 965 ns worst | §11.1, §7.7 | budget (the path's maximum) |
ENG_STEP_MAX_NS / BBO_CROSS_NS
|
15 ns | §8.12, §16.1 | budget (maximum step duration) |
| BBO core load at the design mix | ≈ 0.21 (limit BBO_MAX_LOAD = 0.60) |
§8.12 | budget |
| Lane work per 10-message packet | 185 ns packet path, 225 ns total | §6.7 | budget |
LANE_NS_PER_MSG |
30 ns | §6.7 | budget (all-in) |
Admission limit on age
|
450 ns (n = 1), 325 ns (n = 10) | §6.8 | budget (config table) |
ENG_STEP_FILLS / STEP_FILL_CAP
|
8 / 64 fills per step | §16.1 | budget / cap |
ENG_UNIT_NS |
20 ns between LaneCut polls |
§6.1, §16.1 | budget (maximum) |
ENG_LANE_DEAD_NS |
1_000_000 ns (1 ms) | §14.1, §16.1 | budget (fail-stop threshold) |
| Lane ceiling | 49 lanes ≈ 1.0B msgs/s | §11.7 | budget |
| Clock 5 GHz, cold DRAM line ~90 ns | — | §6.7 | vendor |
-
- Decisions in one page
-
- Overview
-
- The sequential specification
-
- The linearization
-
- Shared structures: the writer map
-
- Visibility and the merged level FIFO
-
- The lane
-
- The cut core, settlement, and physical maintenance
-
- The BBO core
-
- Equivalence with the sequential specification
-
- Replay mode
-
- Performance
-
- Fairness
-
- Book parameters
-
- Failure inside the box
-
- Interfaces to other chapters
-
- Local definitions
-
- Requests to 01
-
- Open questions
-
§14.1:
DEADLINE_GUARD_NS= 20, so the shed threshold is 980 ns. §6.8 still hasDEADLINE_GUARD_NS: u64 = 30and uses 970 throughout (§6.8, §6.9, §11.8). That text is overridden. - §14.17.3: there are three fill TX cores, A, B and C, on cores 3, 5 and 0, each at load ≈ 0.22. OS and control run on core 51. The chapter's two TX cores (§0 D10, §11.7: ~0.33 each) and "control role (core 0)" (§4.1, §8.4, §14.1, §15) are overridden.
-
§14.17.2: on a dedicated lane, lane-stage BUSY = 0. Total BUSY is ≤ 1e-5 at full book load and ≤ 1e-8 at ≤ 20% load. The chapter's unqualified "
BUSY = 0" for dedicated lanes (§6.8, §6.9, §11.8) is overridden. - §14.17.1: adopts the chapter's ack budget of 955 ns typical and 965 ns worst (R14). This replaces §14.2's 935 ns.
-
§14.17.4: each token take is logged as
AcctTake { account, ver, lane }. The chapter's R15 and §6.9 have{ acct, ver }. - §14.17.5: refines §14.14. Maker fills from later continuation steps are bounded from the start of their own step. This answers the chapter's Q15.
-
§14.11: promotes
INV-ENG-1,INV-ENG-2, Advance records, the clamped step-cut rule, andLaneCutwritten by core 4. -
§14.13:
Segment16FIFOs and immutable queue positions replace draft 0.1's intrusive FIFO lists (§4.6). - §14.18 O1, O2, O6: stream-core load, the 947 ns cross fill with 07's 142 ns frame gate (the chapter budgets 880 ns with a 60 ns gate), and the 5 ns/msg and 15 ns figures are budgets, not measurements.
-
00-index: lists R16 (
N_LANES_REF= 49,BBO_CROSS_NS= 15) as already resolved in 01 §5, although §17 still asks for it.
vyrn-cut, vyrn-lane, vyrn-bbo, vyrn-engine; reference book: Vx oracle
The chapter lists 14 open questions (Q1, Q2, Q4–Q6, Q8–Q11, Q12', Q13–Q16). See Open Questions.
Overview
Working on VYRN
Spec
- 00 Index
- 01 Conventions
- 02 Requirements
- 03 Architecture
- 04 Protocol
- 05 Engine
- 06 Platform
- 07 Replication
- 08 Epochs
- 09 Chain
- 10 Accounts, Risk, MD
- 11 Build
- 12 Commitment
- 13 Availability
- 14 Envelope
Engine crates
Other crates
- vyrn-nic
- vyrn-log
- vyrn-data
- vyrn-consensus
- vyrn-replica
- vyrn-epoch
- vyrn-chain
- vyrn-md
- vyrn-sim
- vyrn-bench
Binaries
- vyrn-seq (stub)
- vyrn-validator (stub)
- vyrn-admin
Outside Rust
Reflects main at a9f0d61.