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

WASM: Support Custom Page Sizes proposal #271

Closed
vshymanskyy opened this issue Sep 5, 2024 · 5 comments
Closed

WASM: Support Custom Page Sizes proposal #271

vshymanskyy opened this issue Sep 5, 2024 · 5 comments

Comments

@vshymanskyy
Copy link

vshymanskyy commented Sep 5, 2024

Currently, the WASM page size is fixed at 64KiB, which is rather expensive in some scenarios.

WebAssembly WG proposed a new feature to handle it nicely:
https://github.com/WebAssembly/custom-page-sizes/blob/main/proposals/custom-page-sizes/Overview.md

This would allow generating really tiny wasm modules 🙌

Some notes:

  • Virgil currently generates a wasm file that allocates 3 pages of memory even for the simplest module.
  • Data goes to the second page, I assume the first page is allocated for the stack.
  • I couldn't find v3c options that could influence this behaviour (i.e. allocate a single wasm page with a stack of 4KB)
@vshymanskyy vshymanskyy changed the title Support Custom Page Sizes proposal WASM: Support Custom Page Sizes proposal Sep 5, 2024
@titzer
Copy link
Owner

titzer commented Sep 6, 2024

It's a good suggestion. I started implementing custom page sizes in Wizard, but didn't even think of utilizing it in Virgil. Would certainly make it possible to target embedded Wasm with Virgil, and it's not too much work.

@titzer
Copy link
Owner

titzer commented Sep 6, 2024

WIP, haven't tested it yet: #272

@vshymanskyy What's the status of wasm3's support? I see it as in-progress on the wasm3 repo.

@vshymanskyy
Copy link
Author

It was merged, but wasn't used with any real wasm modules yet. Virgil may present an opportunity 😅

@titzer
Copy link
Owner

titzer commented Sep 6, 2024

Welp, at least one test passed on wasmtime, so I merged the PR. I can test more exhaustively later, but I'll close the issue for now. Feel to reopen if you encounter issues!

@titzer titzer closed this as completed Sep 6, 2024
@vshymanskyy
Copy link
Author

Thanks much!

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

2 participants