WebAssembly / design

WebAssembly Design Documents
http://webassembly.org
Apache License 2.0
11.37k stars 691 forks source link

Thread Proposal and Determinism / Reproducibility #1485

Open adamgfraser opened 10 months ago

adamgfraser commented 10 months ago

One of the advantages of WASM programs has been that with very limited exceptions they are deterministic and so they can also be executed reproducibly. The inclusion of threads has the potential to introduce a new very large exception to that.

Has there been any discussion of supporting features to allow WASM program involving threads to be executed reproducibly? For example recording the ordering in which shared memory interactions occur and allowing a program to be executed with the same ordering as a previous execution?

conrad-watt commented 10 months ago

A deterministic replay mode for arbitrary Wasm programs with shared-memory concurrency would take a lot of engineering to support in a production engine, so I don't think we can mandate this at the language level for the foreseeable future. You can look at the state-of-the-art in native C/C++ compilation for an idea of how feasible it would be for Wasm engines to individually offer this - from a brief search I could only find solutions that are currently research proof-of-concepts.

We are planning to support deterministic replay in the reference interpreter, but this wouldn't handle non-trivial compiled programs.