How jameschensh/frost works
Project type and purpose
• FRoST (“FoundationDB, RocksDB Simulation Tester”) is an open‑source, command‑line deterministic simulation framework written in Zig.
• It exercises “actors” (clients and replicas) against pluggable key‑value backends (FoundationDB, RocksDB, etc.) under a deterministic scheduler and PRNG to compare correctness and performance.
File structure
• Top‑level:
• build.zig – Zig’s build script
• config/ – TOML files for atomic ops and simulator parameters
• scripts/ – helper scripts (e.g., run_fdb_sim.sh)
• src/ – all Zig source code
• src/ substructure:
• main.zig – CLI entry point (“frost”)
• config.zig – loads and parses TOML settings
• prng.zig – deterministic random number generator
• scheduler.zig – event/time‐tick scheduler
• network.zig – message queueing and delivery simulation
• simulator.zig – top‐level orchestrator tying actors, network, scheduler
• actors/ – client.zig & replica.zig, driving read/write ops
• messages.zig – typed message definitions between actors
• db/ – adapter.zig plus backend folders (fdb/, rocksdb/) each with a C binding, build.zig
README’s architectural hints
• It mentions a high‐level SVG in docs/assets showing how clients, replicas, network, scheduler, and storage backends interact.
• Emphasizes deterministic replay via seed, pluggable backends, and “tick” loop.
a. Main components
• CLI / “frost” process
• Configuration Loader (TOML parser)
• Simulator Core
• Scheduler (time/tick manager)
• PRNG (deterministic seed)
• Actor Layer
• Client Actor
• Replica Actor
• Network Layer (virtual message queue)
• Storage Layer (DB Adapters)
• FoundationDB adapter (C binding)
• RocksDB adapter (C binding)
• Output / Logging module
b. Relationships & interactions
1. CLI → Configuration Loader → Simulator Core
2. Simulator Core uses Scheduler & PRNG to drive a loop:
• On each tick, Scheduler awakens Actors
• Actors generate Messages (requests, acks)
• Messages pass to Network Layer
• Network delivers messages back to actors according to schedule
• Replica Actors invoke DB Adapter calls (FDB / RocksDB)
3. Results & logs flow back to Core for reporting
c. Architectural patterns & principles
• Event‐driven, tick‐based deterministic simulation
• Modular plugin pattern for backend adapters
• Clear separation: orchestration (simulator), behavior (actors), communication (network), storage (db)
d. Key technologies & libraries
• Zig 0.14.0 (ZVM) for all implementation
• TOML for config (AtomicOps.toml)
• FoundationDB C API (fdb.c / fdb.zig)
• RocksDB C++ API via C shim (rocks.zig)
Detail
• PRNG and config loader as first‑class components because seed and params drive determinism