Stream: wasmtime

Topic: ✔ Manual usage of CodeMemory for Mmap'd modules


view this post on Zulip spino17 (Aug 30 2024 at 19:33):

I want to manually construct CodeMemory. Right now I am facing difficultly to construct it as it requires MmapVec. I can't use file based APIs as I have a custom persistence layer which has completely different APIs and need to go at the level of CodeMemory and MmapVec. I checked out wasmtime_runtime but they are completely different types not expected by CodeMemory. Any help would be highly appreciated, thanks

view this post on Zulip bjorn3 (Aug 30 2024 at 19:39):

The wasmtime_runtime crate has been merged into the main wasmtime crate a while back. MmapVec is not publicly accessible.

view this post on Zulip spino17 (Aug 30 2024 at 19:40):

@bjorn3 thanks for the response. So what's the way to go if I want to work with CodeMemory APIs ?

view this post on Zulip bjorn3 (Aug 30 2024 at 19:41):

I'm surprised CodeMemory is public at all. I can't find any way it would be useful at all.

view this post on Zulip spino17 (Aug 30 2024 at 19:42):

@bjorn3 yeah, I also thought so. Any specific reason not to expose such APIs ?

view this post on Zulip bjorn3 (Aug 30 2024 at 19:42):

You probably want to use Module::serialize + Module::deserialize if you handle caching yourself without going through files.

view this post on Zulip bjorn3 (Aug 30 2024 at 19:44):

Module::deserialize_file is slightly more efficient as it avoids writing the module to a memfd, but if you are avoiding real files, the compiled module will eventually have to end up in a memfd anyway for wasmtime to be able to mmap it.

view this post on Zulip spino17 (Aug 30 2024 at 19:50):

@bjorn3 thanks for the explanation. This makes sense. Let me try to look into the Module APIs only. Thanks again.

view this post on Zulip Notification Bot (Sep 08 2024 at 13:48):

Till Schneidereit has marked this topic as resolved.


Last updated: Nov 22 2024 at 16:03 UTC