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

Wasmtime/winch sketch #1507

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

graydon
Copy link
Contributor

@graydon graydon commented Jan 9, 2025

This is a preliminary PR, posted for review and comments. Do not merge yet.

It is a followup PR to #1506 that includes it, so you should (a) go read it first and (b) just look at the second commit in this PR when considering its content.

The goal here is to support wasmtime's new winch single-pass compiler as an alternative backend for soroban. It works well enough to run contracts, though it's still quite rough and needs a lot of tuning and polish, and winch itself is not entirely complete either. But it's a promising enough experiment that I wanted to get it stabilized enough to merge -- cfg'ed-off -- while we continue to iterate and experiment with it.

It depends on #1506 because even a single-pass JIT like winch is still orders of magnitude slower to compile code than wasmi is to translate to its IR; high enough latency that it can only possibly makes sense if we have a longer-lived ModuleCache. In fact caching logic (and how to pay for caching) has been one of the substantial barriers to considering JITs up until now, but we have recently had some fairly novel thoughts on how to handle that problem space. So here we are!

The second commit here that does the wasmtime/winch addition is relatively straightforward, once the caching is taken care of. There are some wrinkles around the different gas-transfer API, the different ways of plumbing errors, interacting with linear memory, wrapping dispatch functions, spelling primitive value types, and so forth; but wasmi was built to mirror the wasmtime API fairly closely. For the most part we just "make a new wasmtime object corresponding to any existing wasmi object".

(The code duplication in the dispatch macro and the vm invocation path is especially unfortunate, I can probably factor those a little harder before this is finalized but I wanted to at least get it running and there were a lot of fiddly bits.)

@graydon graydon requested review from sisuresh, dmkozh and jayz22 January 9, 2025 08:17
@graydon graydon force-pushed the reusable-module-cache-and-wasmtime-separately branch from ec165c8 to a92631d Compare January 10, 2025 19:34
@graydon graydon force-pushed the reusable-module-cache-and-wasmtime-separately branch from a92631d to 976fa5d Compare January 10, 2025 19:35
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

Successfully merging this pull request may close these issues.

1 participant