Wasmer 3 upgrade makes Module caching harder. Any ideas? #3829
Replies: 4 comments 10 replies
-
Can you expand a bit more on your use case? You can cache Creating new stores from a module should be fast and cheap. |
Beta Was this translation helpful? Give feedback.
-
Hey @webmaster128, you can add the Engine to |
Beta Was this translation helpful? Give feedback.
-
Trying to rephrase the problem:
This brings us back to an old question: is there a way to do in-memory |
Beta Was this translation helpful? Give feedback.
-
We have same issue. SWC used to store |
Beta Was this translation helpful? Give feedback.
-
In Wasmer 2 we were able to build an in-memory Module cache using something like
HashMap<[u8; 32], Module>
where the key is the checksum of the .wasm file. The use case for doing that is being able to instantiate Wasm files that are used very often very fast in a blockchain setup. Compared to on-disk Module caching it saves us (a) loading from disk and (b) the deserialization into memory. This has shown significant performance improvements.The following diagram shows the caching strategy:
Highlighted in yellow are the places where we clone the Module in order to be able to use it in different threads and store to other caches.
During the upgrade to Wasmer 3 we realized that we have to cache the
(Store, Module)
pair in order to achieve something similar. However, the Store is not cloneable such that we have to useHashMap::remove
to obtain an element from the cache. This also means we can't load modules from cache and then execute them in parallel because they are gone from the cache.Are there some ideas how to address this problem? Are we doing something conceptually wrong?
Some options I see
Arc<Mutex<Store>>
and do constant locking/unlocking from many placesModule
caching and cache serialized modules in cacheArtifacts
and construct Modules from them using a new Store without going through full artifact serializationBut I'm all ear for other suggestions
Beta Was this translation helpful? Give feedback.
All reactions