Stream: wasmtime

Topic: Caching InstancePre


view this post on Zulip Ben Brandt (Sep 25 2024 at 09:14):

Hi! Just a quick question: Is it fine to cache an InstancePre over multiple invocations, potentially being invoked by different users?
Since this is pre passing in the store, I assume it just allows us to cache the compilation/linking step, but if there are any caveats or things to be aware of why I wouldn't want to do this, I'd appreciate it. Thanks!

view this post on Zulip bjorn3 (Sep 25 2024 at 10:20):

Yes, that is it't intended use case.

view this post on Zulip bjorn3 (Sep 25 2024 at 10:20):

Since this is pre passing in the store

According to the docs:

Note that an InstancePre may not be tied to any particular Store if none of the imports it closed over are tied to any particular Store.

view this post on Zulip Ben Brandt (Sep 25 2024 at 10:37):

Perfect thanks! If there is any code that happens at initialization, would this still happen then once it is actually turned into an Instance? Again, I assume so, but don't want to be making any false assumptions. Thanks again for the quick response

view this post on Zulip fitzgen (he/him) (Sep 25 2024 at 14:00):

InstancePre doesn't run or cache the results of any wasm code; it mostly just early-binds imports and massages a few data structures, so that we don't have to do things like string-based import look ups at instantiation time

view this post on Zulip Ben Brandt (Sep 25 2024 at 14:23):

Perfect, thanks!


Last updated: Nov 22 2024 at 17:03 UTC