Stream: git-wasmtime

Topic: wasmtime / issue #2532 Allow capping memory (potentially ...


view this post on Zulip Wasmtime GitHub notifications bot (May 04 2022 at 15:59):

alexcrichton commented on issue #2532:

I believe this can be done with ResourceLimiter nowadays, so closing.

view this post on Zulip Wasmtime GitHub notifications bot (May 04 2022 at 15:59):

alexcrichton closed issue #2532:

<!-- Please try to describe precisely what you would like to do in
Cranelift/Wasmtime and/or expect from it. You can answer the questions below if
they're relevant and delete this text before submitting. Thanks for opening an
issue! -->

Feature

<!-- What is the feature or code improvement you would like to do in
Cranelift/Wasmtime? -->

The ability to force-cap (exported) memories.

Benefit

<!-- What is the value of adding this in Cranelift/Wasmtime? -->

You can't cap at runtime the exported memories from emscripten. You can tell emscripten to import memory instead. WASI doesn't work with imported memory. (arguably this is an emscripten problem but WASI states memories are to be exported, not imported. so if the whole idea of importing memories goes against WASI anyway, why do it that way? being able to cap exported memories would be WASI-compliant on the other hand.)

Implementation

<!-- Do you have an implementation plan, and/or ideas for data structures or
algorithms to use? -->

Just let one be able to set the Memory max to a smaller value, as long as it's no smaller than the current Memory size.

Alternatives

<!-- Have you considered alternative implementations? If so, how are they
better or worse than your proposal? -->

Alternatives:

The only general-purpose solution is this proposal. Whether you have memory imports or exports, this proposal is always guaranteed to work, whereas the alternatives require a lot more cooperation from the wasm module (as they'd have to import memory instead of following WASI spec and exporting it).


Last updated: Dec 23 2024 at 12:05 UTC