Stream: wasi-threads

Topic: virtual memory


view this post on Zulip Georgii Rylov (Nov 30 2023 at 14:52):

Hi, me @Marcin Kolny and @Enrico Loparco were discussing that usage of shared memory in WASI increases chances of crashes - if not enough memory was allocated upfront or too much memory was allocated upfront it can cause a crash.

We discussed an idea of introducing virtual memory when shared memory is used:

  1. From WASM perspective memory looks linear, engine incapsulates mapping
  2. Already allocated block of memory doesn't get reallocated so all shared addresses are valid
  3. If there's not enough memory a new block gets allocated, so there's no crush in such case
  4. Should cause perf degradation when reading/writing memory written in 2 blocks

It makes memory non-linear underneath so I wonder if there was a thread or discussion in WASM/WASI sometime ago about it. So far I found only https://github.com/WebAssembly/multi-memory/blob/main/proposals/multi-memory/Overview.md that can make usage of shared memory less limiting

@Wenyong Huang @Andrew Brown let me know what your thoughts on that

view this post on Zulip Andrew Brown (Nov 30 2023 at 21:06):

The idea reminds me of the memory control proposal, though maybe at a different level: https://github.com/WebAssembly/memory-control/blob/main/proposals/memory-control/Overview.md. Is there a way that could be used to solve the problem you're raising?

view this post on Zulip Andrew Brown (Nov 30 2023 at 21:08):

(Just to check: the problem you're describing does not have to do with linear memory C stacks managed by the toolchain?)

view this post on Zulip Georgii Rylov (Dec 28 2023 at 13:38):

Hey, thank you for the response Andrew

does not have to do with linear memory C stacks managed by the toolchain?)

It does not (in my understanding)

Is there a way that could be used to solve the problem you're raising?

I'm not sure. I guess this proposal would allow to release some memory if I read it right and that's not exactly what we're looking for. But would it allow to grow WASM memory even if shared memory is used? That is the main interest at the moment as max-memory is a very strict requirement


Last updated: Dec 23 2024 at 12:05 UTC