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

Option to avoid per-function allocation of fast interpreter #3921

Open
sasq64 opened this issue Nov 21, 2024 · 0 comments
Open

Option to avoid per-function allocation of fast interpreter #3921

sasq64 opened this issue Nov 21, 2024 · 0 comments

Comments

@sasq64
Copy link

sasq64 commented Nov 21, 2024

Feature

Option to make the fast interpreter not allocate so much memory;

Right now, the fast interpreter allocates close to 1000 bytes of memory for each function in the web assembly which is a lot of RAM for an embedded environment.

I would like to be able to turn avoid this, even if it means letting the code run slower.

Also because the fast interpreter can be run from read-only (flash) memory, while the slow interpreter can not, and the wasm binary must be copied into RAM.

Benefit

Reducing RAM usage.

Implementation

The big culprit is in wasm_loader_ctx_init() where the two structs BranchBlock and Const constitute allocations of 192 + 704 = 896 bytes of memory per function.

Alternatives

Alternative could be to let the slow interpreter work from read-only memory, to avoid the memory needed when copying it into RAM.

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