MadSim
Magical Automatic Deterministic Simulator for distributed systems.
Deterministic simulation
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.
Ensure Deterministic
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.
Related Projects
- MadRaft: The labs of Raft consensus algorithm derived from MIT 6.824 and PingCAP Talent Plan.
License
Apache License 2.0