From d03fb04cd04801c5f0e60edac83879f7a2cc4fb8 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Tue, 7 Oct 2025 09:04:28 -0700 Subject: [PATCH] Enable relaxed-simd-deterministic for Viceroy. The Wasm spec defines several [relaxed SIMD instructions], which are permitted to have nondeterministic results, in order to accommodate differences between hardware CPU architectures. However, rather than being fully nondeterministic, it requires them to be deterministic within a run of a program, so that programs can assume that whatever behavior they see the first time they use a relaxed SIMD instruction will continue to be the behavior for the rest of the run of the program. Fastly's Compute platform makes use of snapshotting using [wizer] to optimize program startup times. This involves running the program initialization on one machine, snapshotting the program, and then resuming the program on another. To ensure that the relaxed SIMD instructions don't change behavior across the snapshot and resume, enable the deterministic lowerings. [relaxed SIMD instructions]: https://webassembly.github.io/spec/core/exec/numerics.html#relaxed-operations [wizer]: https://github.com/bytecodealliance/wizer --- src/execute.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/execute.rs b/src/execute.rs index b6c7f774..d1b4f770 100644 --- a/src/execute.rs +++ b/src/execute.rs @@ -1025,6 +1025,15 @@ fn configure_wasmtime( config.wasm_component_model(true); } + // Wasm permits the "relaxed" instructions to be nondeterministic + // between runs, but requires them to be deterministic within runs. + // Snapshotting a program's execution to avoid redundantly running + // initialization code on each request is an important optimization, + // so we enable deterministic lowerings for relaxed SIMD to ensure + // that it works consistently even if the initialization runs on a + // different host architecture. + config.relaxed_simd_deterministic(true); + config }