Stream: git-wasmtime

Topic: wasmtime / PR #11148 Avoid cloning and dropping `Arc`s in...


view this post on Zulip Wasmtime GitHub notifications bot (Jun 27 2025 at 17:19):

fitzgen opened PR #11148 from fitzgen:no-clone-drop-arc-in-vmmemory-method to bytecodealliance:main:

Getting the base pointer from the underlying dyn RuntimeLinearMemory involved getting a MemoryBase which is potentially an MmapOffset which itself contains an Arc<Mmap>, and we would then call base.as_non_null() to turn this into a raw pointer, and then we would drop the MemoryBase which ultimately drops the Arc<Mmap>. So that's an Arc clone and drop just to get a VMMemoryDefinition, which is just a pointer and a length, essentially a slice of the linear memory. And, among other places, we call LocalMemory::vmmemory to get the GC heap's memory base and bound every time we access a GC object from Rust (for example, during collections).

Altogether, this removes another 30% of runtime from the testcase in https://github.com/bytecodealliance/wasmtime/issues/11141

<!--
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 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 (Jun 27 2025 at 17:19):

fitzgen requested dicej for a review on PR #11148.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 27 2025 at 17:19):

fitzgen requested wasmtime-core-reviewers for a review on PR #11148.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 27 2025 at 17:27):

fitzgen commented on PR #11148:

All that said, I don't love how this PR introduces a second version of the "same" method. It might be nicer to instead add a vmmemory method to RuntimeLinearMemory and push VMMemoryDefinition construction down to implementations of that trait, rather than tying together the results of different RuntimeLinearMemory methods in LocalMemory.

That would actually let us avoid an indirect call too:

Note that the "now" sequence has two indirect calls while the alternative has only one.

I'm going to whip this alternative up real quick and then update this PR.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 27 2025 at 17:48):

fitzgen updated PR #11148.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 27 2025 at 17:56):

fitzgen commented on PR #11148:

I'm going to whip this alternative up real quick and then update this PR.

I've pushed a commit that implements this.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 27 2025 at 18:50):

alexcrichton submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 27 2025 at 19:15):

alexcrichton merged PR #11148.


Last updated: Dec 06 2025 at 06:05 UTC