Skip to content
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

Figure out situation regarding resetting the runtime Wasm VM #760

Open
tomaka opened this issue Apr 12, 2021 · 2 comments
Open

Figure out situation regarding resetting the runtime Wasm VM #760

tomaka opened this issue Apr 12, 2021 · 2 comments

Comments

@tomaka
Copy link
Contributor

tomaka commented Apr 12, 2021

At the moment, virtual machines are re-used when executing multiple runtime functions in a row (even across blocks).
However, the memory of the virtual machines isn't zeroed, for performance reasons.
The allocator, however, is re-recreated between each call. This might be problematic because the allocator works by writing data in the memory. The allocator might assume that memory is in a certain state when it's not.

The whole situation should be figured out. Is it even correct to not reset the memory?

cc #132

@tomaka
Copy link
Contributor Author

tomaka commented Oct 13, 2022

Another important thing to note is that the Wasm instance also contains a stack and globals, which need to be reset as well.
This means that we should recreate the Instance from scratch every time no matter what.

@tomaka tomaka changed the title Figure out situation regarding allocator and zero-ing memory Figure out situation regarding resetting the Wasm VM Oct 13, 2022
@tomaka tomaka changed the title Figure out situation regarding resetting the Wasm VM Figure out situation regarding resetting the runtime Wasm VM Oct 13, 2022
@tomaka
Copy link
Contributor Author

tomaka commented Oct 13, 2022

Some notes from lil pep:

if you use wasmtime, use the pooling allocator. If not, and you are on Linux (not other nixes), use madvise(DONT_NEED), if you are on macOS help yourself or maybe Alex T. might help you. If you are in browser I guess the best way is to rely on the browser engine if possible. If not, I wonder maybe web supports quick tricks on buffers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant