Stream: wasmtime

Topic: Possible determinism issues


view this post on Zulip Olexiy Kulchitskiy (Apr 27 2022 at 16:09):

Hi, guys! I'm new to all this WASM stuff and looking for deterministic WASM runtime (for some POC). Please advise whether Wasmtime is handling non-determinism issues and if yes, how (would be nice to point to some article/code)?

view this post on Zulip Chris Fallin (Apr 27 2022 at 17:31):

Hi @Olexiy Kulchitskiy -- the execution of Wasm in Wasmtime should be completely deterministic with a few exceptions:

view this post on Zulip Chris Fallin (Apr 27 2022 at 17:32):

Ah, stack depth as well; the point at which one gets a stack-overflow trap is implementation-defined (but that should not be observable in any normally-returning Wasm call, as the trap terminates the instance)

view this post on Zulip bjorn3 (Apr 27 2022 at 17:56):

And the memory allocation limit.

view this post on Zulip Dan Gohman (Apr 27 2022 at 18:03):

You may also want to use the static_memory_forced API, to prevent memory.grow allocation from failing nondeterministically.

view this post on Zulip Olexiy Kulchitskiy (Apr 27 2022 at 18:57):

got it. Thank you

view this post on Zulip Lars Hansen (May 02 2022 at 08:44):

Relaxed SIMD will be deterministic per-platform but will appear nondeterministic across platforms - basically the same problem as for NaNs, but will require a different solution.

view this post on Zulip dakom (Mar 26 2026 at 14:16):

Resurrecting this after a while, could someone expand on this for wasi-p2, and maybe even wasi-p3 with async in mind?

view this post on Zulip Joel Dice (Mar 26 2026 at 14:37):

You could start by doing a text search for "determinstic" in https://github.com/WebAssembly/component-model/blob/main/design/mvp/CanonicalABI.md. Async task and thread scheduling are indeed nondeterministic, spec-wise, in the default profile, but enabling the deterministic profile can reduce (and maybe eliminate?) that nondeterminism.

view this post on Zulip fitzgen (he/him) (Mar 26 2026 at 15:43):

@dakom have you read https://docs.wasmtime.dev/examples-deterministic-wasm-execution.html already? it attempts to answer your original question, if anything is missing we should update that page to contain it

view this post on Zulip dakom (Mar 26 2026 at 17:37):

@fitzgen (he/him) - that's an excellent resource, thank you!!

So I think my only high-level question is how this page might need to be updated for p3/async?

view this post on Zulip fitzgen (he/him) (Mar 26 2026 at 17:39):

that all falls under "imports" -- if you want determinism, you need to make sure your imports are deterministic (or you are deterministically replaying a recording of non-deterministic imports) and http APIs are not particularly deterministic

view this post on Zulip Joel Dice (Mar 26 2026 at 17:48):

It partially falls under "imports", but some of the "imports" for async are intrinsics over which the embedder has no control, and Wasmtime's implementation of some of those intrinsics are non-deterministic, with no option (yet) to make them deterministic.

view this post on Zulip dakom (Mar 26 2026 at 17:49):

It would also depend on the runtime being run in a deterministic way, e.g. tokio, right?

view this post on Zulip fitzgen (he/him) (Mar 26 2026 at 17:49):

ah I would have assumed that like task scheduling was deterministic assuming that the imports themselves were deterministic

view this post on Zulip Joel Dice (Mar 26 2026 at 17:51):

I guess I would say we haven't made an effort to make task scheduling deterministic yet, so if it is, that's a happy coincidence :)

view this post on Zulip Joel Dice (Mar 26 2026 at 17:54):

@dakom FYI Wasmtime's async support doesn't depend on tokio (although wasmtime-wasi does), so you could bring your own deterministic executor if desired.

view this post on Zulip Joel Dice (Mar 26 2026 at 17:55):

But I suspect there are sources of nondeterminism inside Wasmtime's scheduling even with a deterministic executor, just because we haven't tried to avoid that yet.


Last updated: Apr 12 2026 at 23:10 UTC