{"id":13648616,"url":"https://github.com/madsim-rs/madsim","last_synced_at":"2025-10-03T14:04:08.641Z","repository":{"id":37291693,"uuid":"389256017","full_name":"madsim-rs/madsim","owner":"madsim-rs","description":"Magical Deterministic Simulator for distributed systems in Rust.","archived":false,"fork":false,"pushed_at":"2025-01-09T09:17:42.000Z","size":1207,"stargazers_count":823,"open_issues_count":29,"forks_count":56,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-04-15T06:38:27.233Z","etag":null,"topics":["deterministic","distributed-systems","simulator"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/madsim-rs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-07-25T03:57:34.000Z","updated_at":"2025-04-13T12:31:51.000Z","dependencies_parsed_at":"2023-10-11T11:28:45.471Z","dependency_job_id":"8f662f0b-dfc5-46d3-8e49-71101edaaf00","html_url":"https://github.com/madsim-rs/madsim","commit_stats":{"total_commits":300,"total_committers":14,"mean_commits":"21.428571428571427","dds":0.07999999999999996,"last_synced_commit":"4d77c984654d1a373e4c9ca179c8c6adcdc94b09"},"previous_names":["madsys-dev/madsim"],"tags_count":37,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madsim-rs%2Fmadsim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madsim-rs%2Fmadsim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madsim-rs%2Fmadsim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madsim-rs%2Fmadsim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/madsim-rs","download_url":"https://codeload.github.com/madsim-rs/madsim/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250232392,"owners_count":21396632,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deterministic","distributed-systems","simulator"],"created_at":"2024-08-02T01:04:23.691Z","updated_at":"2025-10-03T14:04:03.618Z","avatar_url":"https://github.com/madsim-rs.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# MadSim\n\n[![Crate](https://img.shields.io/crates/v/madsim.svg)](https://crates.io/crates/madsim)\n[![Docs](https://docs.rs/madsim/badge.svg)](https://docs.rs/madsim)\n[![CI](https://github.com/madsim-rs/madsim/workflows/CI/badge.svg?branch=main)](https://github.com/madsim-rs/madsim/actions)\n\nMagical Deterministic Simulator for distributed systems.\n\n## Deterministic Simulation Testing\n\nMadSim is a Rust async runtime similar to tokio, but with a key feature called **deterministic simulation**.\n\nThe main idea is borrowed from [FoundationDB](https://www.youtube.com/watch?v=4fFDFbi3toc) and [sled simulation guide](https://sled.rs/simulation.html).\nYour code should be able to deterministically execute on top of a simulator.\nThe simulator will amplify randomness, create chaos and inject failures into your system.\nA lot of hidden bugs may be revealed, which you can then deterministically reproduce until they are fixed.\nIf your system can survive such chaos, you will have more confidence in deploying your system in the real world.\n\nHowever, implementing deterministic simulation is difficult.\nAll I/O-related interfaces must be mocked during the simulation, and all uncertainties should be eliminated.\nThis project is created to make that easy.\n\nA part of the implementation of this crate is inspired by [tokio-rs/simulation](https://github.com/tokio-rs/simulation).\n\nSee also the blog posts for a detailed writeup:\n- [Deterministic Simulation: A New Era of Distributed System Testing (Part 1 of 2)](https://www.risingwave.com/blog/deterministic-simulation-a-new-era-of-distributed-system-testing/)\n- [Applying Deterministic Simulation: The RisingWave Story (Part 2 of 2)](https://www.risingwave.com/blog/applying-deterministic-simulation-the-risingwave-story-part-2-of-2/)\n\n## Usage\n\nAdd the following lines to your Cargo.toml:\n\n```toml\n[dependencies]\nmadsim = \"0.2\"\n```\n\nIf your project depends on the following crates, replace them by our simulators:\n\n```toml\n[dependencies]\ntokio = { version = \"0.2\", package = \"madsim-tokio\" }\ntonic = { version = \"0.5\", package = \"madsim-tonic\" }\netcd-client = { version = \"0.4\", package = \"madsim-etcd-client\" }\nrdkafka = { version = \"0.3\", package = \"madsim-rdkafka\" }\naws-sdk-s3 = { version = \"0.5\", package = \"madsim-aws-sdk-s3\" }\n\n[dev-dependencies]\ntonic-build = { version = \"0.5\", package = \"madsim-tonic-build\" }\n```\n\nIf your dependency graph includes the following crates, replace them by our patched version:\n\n```toml\n[patch.crates-io]\nquanta = { git = \"https://github.com/madsim-rs/quanta.git\", rev = \"948bdc3\" }\ngetrandom = { git = \"https://github.com/madsim-rs/getrandom.git\", rev = \"8daf97e\" }\ntokio-retry = { git = \"https://github.com/madsim-rs/rust-tokio-retry.git\", rev = \"95e2fd3\" }\ntokio-postgres = { git = \"https://github.com/madsim-rs/rust-postgres.git\", rev = \"4538cd6\" }\ntokio-stream = { git = \"https://github.com/madsim-rs/tokio.git\", rev = \"ab251ad\" }\n```\n\nWhen built normally, these crates are identical to the original ones.\n\nTo run your code on the simulator, enable the config `madsim`:\n\n```sh\nRUSTFLAGS=\"--cfg madsim\" cargo test\n```\n\nNow you have gotten rid of tokio/tonic and you are in the simulation world!\n\nWe provide a set of APIs to control the simulator. You can use them to kill a process, disconnect the network, inject failures, etc.\nCheck out the [documentation](https://docs.rs/madsim) and search for the `madsim` feature to learn more usages.\n\n## Projects\n\n* [MadRaft](https://github.com/madsim-rs/madraft): The labs of Raft consensus algorithm derived from MIT 6.824 and PingCAP Talent Plan.\n* [RisingWave](https://github.com/risingwavelabs/risingwave): A distributed SQL database for stream processing that uses MadSim for deterministic testing.\n\n## License\n\nApache License 2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmadsim-rs%2Fmadsim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmadsim-rs%2Fmadsim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmadsim-rs%2Fmadsim/lists"}