Skip to main content

Module engine_state_snapshot

Module engine_state_snapshot 

Source
Expand description

Persistent engine state snapshots for fast restart recovery.

After journal replay the engine writes a snapshot of its core state (orderbooks, counters, expired instruments) to disk. On the next restart the snapshot is loaded first, and only the delta since the snapshot’s last_command_id needs to be replayed from the journal.

File format: [msgpack payload][4-byte CRC32 LE]

Atomic write: temp β†’ fsync β†’ rename (same as journal checkpoint writes).

StructsΒ§

EngineStateSnapshot
Persistent engine state snapshot for fast restart recovery.
LegacyEngineStateSnapshot πŸ”’
Pre-CALL-1707 snapshot layout without last_balance_update_seq.
LegacyEngineStateSnapshotPreAppendOnlyV2 πŸ”’
Older v2 layout from before snapshot fields were made append-only.
OrderSnapshotEntry
A single order in the snapshot, matching OrderBook::get_all_orders() output.
VolatilitySurfaceSnapshot

ConstantsΒ§

LEGACY_BALANCE_UPDATE_SEQ_MIGRATION_EPOCH πŸ”’
LEGACY_SNAPSHOT_VERSION_V1 πŸ”’
LEGACY_SNAPSHOT_VERSION_V2 πŸ”’
SNAPSHOT_CRC πŸ”’
SNAPSHOT_VERSION πŸ”’
Current snapshot format version.

FunctionsΒ§

build_snapshot
Build a snapshot from current engine state, tagged with the checkpoint boundary.
decode_legacy_engine_state_snapshot πŸ”’
msgpack_array_start πŸ”’
msgpack_map_start πŸ”’
msgpack_str_at πŸ”’
msgpack_u32_at πŸ”’
read_snapshot
Read a snapshot from disk with CRC32 integrity verification.
snapshot_order_count
Count total orders across all orderbooks in a snapshot.
snapshot_path_from_wal_path
Derive the snapshot file path from the WAL path.
snapshot_payload_version πŸ”’
write_snapshot
Write a snapshot atomically: temp β†’ fsync β†’ rename β†’ dir sync.