Stream: git-wasmtime

Topic: wasmtime / issue #4250 Wasmtime should optimize away atom...


view this post on Zulip Wasmtime GitHub notifications bot (Jun 09 2022 at 14:41):

alexcrichton labeled issue #4250:

Part of the threads proposal in wasm is to add a "shared" flag to memory. Wasmtime statically knows that if a memory is not shared then atomic operations are not necessary because the memory cannot be concurrently modified. The atomic rmw instructions added in the threads proposal work on all memories, however.

Wasmtime should translate the atomic operations differently depending on whether the memory they're referencing is shared or not, automatically falling back to non-atomic operations on non-shared memories. While this isn't a huge concern today if threads become more prevalent in the wasm tooling ecosystem it might be more common to use atomic operations unconditionally regardless of whether memory is shared or not. For example the Rust wasm32-wasi target could perhaps one day use a real implementation for mutexes so whether or not memory is shared is a link-time flag rather than a build-time flag as it is today. In this situation it'll likely be faster for Wasmtime to use non-atomic operations instead of atomic operations when memory isn't shared.


Last updated: Dec 23 2024 at 12:05 UTC