lunatic-solutions / lunatic

Lunatic is an Erlang-inspired runtime for WebAssembly
https://lunatic.solutions
Apache License 2.0
4.61k stars 138 forks source link

Implement a discrete event simulator #90

Open teymour-aldridge opened 2 years ago

teymour-aldridge commented 2 years ago

As described in https://sled.rs/simulation.html.

teymour-aldridge commented 2 years ago

I'm currently experimenting with this.

bkolobara commented 2 years ago

I have been looking into this since I started working on distributed lunatic. My conclusion is that this would only be feasible if we shipped our own wasm execution engine (currently we use Wasmtime). We lose a lot of information when Wasmtime jit compiles the wasm code to machine code. I believe that we require a bit more granularity and control around the suspension points to make a truly deterministic test environment. Especially around sensitive edge cases, like what happens if a process links to another, but the other one doesn't get scheduled until the first one has already trapped and didn't finish establishing the link. This are some scenarios were we could tremendously benefit from a discrete event simulator.

Replacing Wasmtime with our own engine would have other benefits too and allow us to build something tailored around lunatic's use cases. It's also something I would be really excited to work on. The only downside is that it would be a huge undertaking and take us months/years to get to a usable state :).