Skip to content

Wasmtime/winch sketch#1507

Draft
graydon wants to merge 4 commits intostellar:mainfrom
graydon:reusable-module-cache-and-wasmtime-separately
Draft

Wasmtime/winch sketch#1507
graydon wants to merge 4 commits intostellar:mainfrom
graydon:reusable-module-cache-and-wasmtime-separately

Conversation

@graydon
Copy link
Copy Markdown
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 #1530 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 #1530 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 dmkozh, jayz22 and sisuresh January 9, 2025 08:17
@graydon graydon force-pushed the reusable-module-cache-and-wasmtime-separately branch 2 times, most recently from a92631d to 976fa5d Compare January 10, 2025 19:35
@graydon graydon force-pushed the reusable-module-cache-and-wasmtime-separately branch from 976fa5d to 474b216 Compare March 29, 2025 08:00
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