-
Notifications
You must be signed in to change notification settings - Fork 833
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What does instance.clone() actually do? #2796
Comments
|
I was able to rollback my wasm instance state by storing the |
I suspect that works in some cases. You might also have to consider (I've thought about this at some point, but gave up, because you can't save state if the wasm stack isn't empty (and I suspect it's generally impossible if you have stuff like Host -> WASM -> Host -> WASM -> save-function)) |
The module is only ever created once. Rollbacks when occurring only happen when the WASM stack is empty, and saving/loading of these states is determined by the host when triggered due to network conditions. So I'm not really creating any new instances or modules, it's more like hot-swapping the memory for this already-running instance to rollback and continue with correct inputs. |
Summary
I'm attempting to implement a roll-back system for currently-running instances. I see that instance supports a
.clone()
function but I'm not too sure what exactly is happening inside of there. Does cloning an instance simply create a new pointer/reference to the already-existing instance? Or does it perform a copy of the stateful instance and generate a new one? If it is not the latter, how can this be accomplished?Additional details
Ideally, my code functions in the following way: constantly calling a wasm defined
update()
function and saving that stateful instance in memory somewhere. Should a rollback be required, load that previously executing instance, then continue callupdate()
again with new values, and re-write the old states. Is there a way I can clone an already-running instance (including it's full state), to be able to run or resume it again later? Isdeep copy
the correct term here?Alternatively, would cloning
Store
potentially work in this case, or does it run into the same issue where it's still pointing to the same underlying instances? Would there be a way I could just memcpy (either a state or instance's) activememory
and move/copy values in and out of the instance?Could be related to - #480
The text was updated successfully, but these errors were encountered: