You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now we seralize a Module in InMemoryCache::store and deserialize it in InMemoryCache::load. This operation is costy, as discovered here: #603. Being able to avoid it brings down startup times of contracts cached in memory from 1-2ms to about 50µs.
Instantiate multiple instances from one Module without using a new Store. This is the recommended way to create many instances.
Why use a new Store for every instance
An InMemoryCache lives as long as a higher level Cache. Right now, pass a memory_limit via InstanceOptions to Cache::get_instance. This allows us to use a different memory limit for every Instance. However, this flexibility is not needed at all. CosmWasm/wasmvm@bbeb7a9#diff-24ee2abbb4556b154f9bada8de5f7961a957bd2267b3cdeeeaf23e619769c5c7 shows how one memory limit is configured for all contract executions of one VM. So if we remove memory_limit from InstanceOptions and store it as a field to the Cache, we can use the same memory limit for all instances. Then we don't need a new Store for every instance. This allows us to cache Modules directly in InMemoryCache.
The text was updated successfully, but these errors were encountered:
Right now we seralize a
Module
inInMemoryCache::store
and deserialize it inInMemoryCache::load
. This operation is costy, as discovered here: #603. Being able to avoid it brings down startup times of contracts cached in memory from 1-2ms to about 50µs.Using Wasmer 0.17, we could cache modules in memory without serialization but with Wasmer 1.0 we create new
Module
s in everyload
in order to be able to set a newStore
.Possible solutions
Store
of aModule
: In Allow decomposition and composition of Modules without serialization wasmerio/wasmer#1933 it is discussed if we can replace a Store of an existing module but it is unclear if this is doable.Module
from anArtifact
without serializing. This does not work, see Cache Artifacts directly instead of their serialization #666.Module
without using a newStore
. This is the recommended way to create many instances.Why use a new Store for every instance
An
InMemoryCache
lives as long as a higher levelCache
. Right now, pass amemory_limit
viaInstanceOptions
toCache::get_instance
. This allows us to use a different memory limit for everyInstance
. However, this flexibility is not needed at all. CosmWasm/wasmvm@bbeb7a9#diff-24ee2abbb4556b154f9bada8de5f7961a957bd2267b3cdeeeaf23e619769c5c7 shows how one memory limit is configured for all contract executions of oneVM
. So if we removememory_limit
fromInstanceOptions
and store it as a field to theCache
, we can use the same memory limit for all instances. Then we don't need a newStore
for every instance. This allows us to cacheModule
s directly inInMemoryCache
.The text was updated successfully, but these errors were encountered: