Stream: git-wasmtime

Topic: wasmtime / PR #5208 Implement support for dynamic memorie...


view this post on Zulip Wasmtime GitHub notifications bot (Nov 04 2022 at 21:51):

alexcrichton opened PR #5208 from pooling-dynamic to main:

This is a continuation of the thrust in #5207 for reducing page faults and lock contention when using the pooling allocator. To that end this commit implements support for efficient memory management in the pooling allocator when using wasm that is instrumented with bounds checks.

The MemoryImageSlot type now avoids unconditionally shrinking memory back to its initial size during the clear_and_remain_ready operation, instead deferring optional resizing of memory to the subsequent call to instantiate when the slot is reused. The instantiation portion then takes the "memory style" as an argument which dictates whether the accessible memory must be precisely fit or whether it's allowed to exceed the maximum. This in effect enables skipping a call to mprotect to shrink the heap when dynamic memory checks are enabled.

In terms of page fault and contention this should improve the situation by:

The major cost of choosing this strategy is naturally the performance hit of the wasm itself. This is being looked at in PRs such as #5190 to improve Wasmtime's story here.

This commit does not implement any new configuration options for Wasmtime but instead reinterprets existing configuration options. The pooling allocator no longer unconditionally sets
static_memory_bound_is_maximum and then implements support necessary for this memory type. This other change to this commit is that the Tunables::static_memory_bound configuration option is no longer gating on the creation of a MemoryPool and it will now appropriately size to instance_limits.memory_pages if the static_memory_bound is to small. This is done to accomodate fuzzing more easily where the static_memory_bound will become small during fuzzing and otherwise the configuration would be rejected and require manual handling. The spirit of the MemoryPool is one of large virtual address space reservations anyway so it seemed reasonable to interpret the configuration this way.

<!--

Please ensure that the following steps are all taken care of before submitting
the PR.

Please ensure all communication adheres to the code of conduct.
-->

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2022 at 05:12):

alexcrichton updated PR #5208 from pooling-dynamic to main.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 07 2022 at 18:12):

alexcrichton requested peterhuene for a review on PR #5208.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 08 2022 at 20:33):

peterhuene submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 08 2022 at 20:43):

alexcrichton merged PR #5208.


Last updated: Dec 23 2024 at 12:05 UTC