Stream: git-wasmtime

Topic: wasmtime / PR #15381 Runtime: optimize wasm-to-host inval...


view this post on Zulip Wasmtime GitHub notifications bot (Nov 19 2026 at 19:33):

cfallin opened PR #15381 from cfallin:fix-invalidate-hook-perf to bytecodealliance:main:

On some libcalls (e.g. memory.copy/memory.fill), which are very hot, the Wasm-to-host transition invoking invalidation logic can be observably quite expensive (5-10% benchmark hits).

We introduced a GC-epoch bump for unrooted refs recently in #15191, and then refactored/generalized the epoch-bump to handle the "execution version" scheme used by FrameHandles in #15358 as well. Starting with the former and continuing with the latter, we required a vtable-indirect method invocation on the &mut dyn VMStore to do this epoch-bump from within catch_unwind_and_record_trap.

This PR introduces a small "effect scheme" framework for libcalls. The idea is that if we know a libcall is either (i) completely pure, or (ii) only mutates state on its own in a way that is (ii-a) tracked (e.g. for watchpoints) separately, and (ii-b) still a leaf function, then we don't need to invalidate handles. It's as-if the Wasm code had inlined all the implementation of the libcall -- we just happen to place it in the runtime instead.

So we pass a LibCallEffect to catch_unwind_and_record_trap now, and gate the on_wasm_to_host_transition indirect call on it. Together with an inlining annotation, we const-fold this check in each libcall entry point so in practice we don't have any code at all in the fast libcalls like memcpy/memmove (and recover the tail-call to memcpy/memmove that we had before).

This eliminates all perf regression seen from just-before-#15191 to present. Thus, it fixes #15342.

<!--
Please make sure you include the following information:

Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.html

Please review the Bytecode Alliance's AI tool usage policy at
https://github.com/bytecodealliance/governance/blob/main/AI_TOOL_POLICY.md

Please ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->

view this post on Zulip Wasmtime GitHub notifications bot (Nov 19 2026 at 19:33):

cfallin removed the review request for wasmtime-core-reviewers from PR #15381.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 19 2026 at 19:33):

cfallin requested dicej for a review on PR #15381.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 19 2026 at 19:33):

cfallin requested wasmtime-core-reviewers for a review on PR #15381.


Last updated: Nov 19 2026 at 20:05 UTC