-
Notifications
You must be signed in to change notification settings - Fork 12
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
feat: support jspi on available platforms #100
Conversation
This allows us to use async host functions on the main thread on supported platforms. (Right now that's just Node v23+, as far as I know.)
70c1248
to
89aa445
Compare
e9c5ab0
to
a1deb53
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome! As I mentioned in a comment I'm slightly out of my depth here but from what I can tell the updates look good. Windows CI is failing, but once that is fixed I am in favor of merging this.
I know you mentioned background plugins are slower in the benchmark PR, would this have the potential to improve performance while still enabling async functions?
new(fn: CallableFunction): any | ||
} | ||
|
||
const AsyncFunction = (async () => { }).constructor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is when I realized I knew nothing about JS. Usually it happens a little further down the diff 😅
Yep! On platforms that support JSPI, we should be able to instantiate foreground plugins that use async host functions, which clocked in at around 190-231 microseconds per instantiation. |
playwright's safari on windows does not include webassembly support!
6d327bd
to
800b781
Compare
This allows us to use async host functions on the main thread on supported platforms. (Right now that's just Node v23+, as far as I know.)
Additionally: this PR also removes WASIp1 support for Deno, since WASI support is broken there as of Deno v2.
Example use:
(Note: there might still be a good reason to keep
background-worker
around since –AFAICT– suspending Wasm still blocks the main thread while executing. However, we might be able to make the threaded version a lot nicer! Now that we canawait
in host functions on the background thread, we don't need to atomically copy data down from the host anymore, we can justpostMessage
the new blocks down. Best of both worlds! This represents future work outside the scope of this PR, however.)