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
For the context, the current logic we have works like this:
// host
let mut serialized = serialize_xxx();
for (wasm_instance in instances) {
serialized = wasm_instance.run(serialized);
}
deserialize(serialized);
Per each wasm_instance.run() we creates a new store, import_object, and Memory which involves copy whole serialized byte into guest's memory spaces as well as serialization / deserialization. If there's way to create a single memory and all the instances share it I hope we could reduce redundant copy.
Super naive attempt like below
let memory: &Memory = get_memory_ref();
let import_object = imports! {
"env" => {
"mem" => memory
}
}
doesn't seem to work, as well as attempting to make single instance to import_object is a challenging to invoke chain_front() to create chained resolver for chaining wasiEnv like
if is_wasi_module() {
let wasi_env_import_object = wasi_env.import_object(&module)?;
let chained_resolver = import_object.chain_front(wasi_env_import_object); //looks like this triggers move?
Instance::new(&module, &chained_resolver)
} else {
Instance::new(&module, &import_object);
}
I feel I miss some obivous thing, is there some quick ref I can try to peek somewhere?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Peeking back some old thread, I came to find this one https://spectrum.chat/wasmer/runtime/share-memory-region-between-wasm-instances~3abfaa44-8fc8-4401-8590-1ec3bfbede5d?m=MTU3MDA0MzY0MzA4Nw==
And curious if this is still a viable way to do.
For the context, the current logic we have works like this:
Per each
wasm_instance.run()
we creates a new store,import_object
, andMemory
which involves copy whole serialized byte into guest's memory spaces as well as serialization / deserialization. If there's way to create a single memory and all the instances share it I hope we could reduce redundant copy.Super naive attempt like below
doesn't seem to work, as well as attempting to make single instance to
import_object
is a challenging to invokechain_front()
to create chained resolver for chaining wasiEnv likeI feel I miss some obivous thing, is there some quick ref I can try to peek somewhere?
Beta Was this translation helpful? Give feedback.
All reactions