Skip to content

Commit d03fb04

Browse files
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
1 parent f2ea186 commit d03fb04

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/execute.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,6 +1025,15 @@ fn configure_wasmtime(
10251025
config.wasm_component_model(true);
10261026
}
10271027

1028+
// Wasm permits the "relaxed" instructions to be nondeterministic
1029+
// between runs, but requires them to be deterministic within runs.
1030+
// Snapshotting a program's execution to avoid redundantly running
1031+
// initialization code on each request is an important optimization,
1032+
// so we enable deterministic lowerings for relaxed SIMD to ensure
1033+
// that it works consistently even if the initialization runs on a
1034+
// different host architecture.
1035+
config.relaxed_simd_deterministic(true);
1036+
10281037
config
10291038
}
10301039

0 commit comments

Comments
 (0)