Magical Automatic Deterministic Simulator for distributed systems.
MadSim is a Rust async runtime similar to tokio, but with a key feature called deterministic simulation.
The main idea is borrowed from sled simulation guide and FoundationDB. Part of the implementation is inspired by tokio-rs/simulation.
Developers should eliminate any randomness in the application code. That's not easy.
Here are some tips to avoid randomness:
- Use
futures::select_biased
instead offutures::select
macro. - Do not iterate through a
HashMap
.
To make sure your code is deterministic, run your test with the following environment variable:
MADSIM_TEST_CHECK_DETERMINISTIC=1
Your test will be run at least twice with the same seed. If any non-deterministic detected, it will panic as soon as possible.
- MadRaft: The labs of Raft consensus algorithm derived from MIT 6.824 and PingCAP Talent Plan.
Apache License 2.0