Comments (4)
Context This would solve a headache I have (currently using wasm3): I want an event main loop, but once I start WASM, it has to do everything blocking, unless I make the WASM code async. Since WASM is already interpreted and should be trivially re-entrant, it seems the interpreter could do more to help me "get out" again while waiting for I/O. (Running on the second core of RP2040.)
It should be possible to solve this headache with Wasmi's resumable function calls:
https://docs.rs/wasmi/0.32.1/wasmi/struct.Func.html#method.call_resumable
When using Wasmi's resumable functions, errors returned from called host functions will yield back the execution and also make it possible for the host side to resolve the error and resume the call afterwards. So whenever your host functions would perform I/O tasks you could instead return a host error that stores all the needed information about the I/O operation. Then Wasmi would yield control back to the host side where the async I/O operation could be performed just to resume the Wasm execution via Wasmi, finally.
This is how smoldot solves a very similar use case. (https://github.com/smol-dot/smoldot/blob/main/lib/src/executor/vm/interpreter.rs)
Some people believe that resumable calls are a more powerful concept than async calls.
from wasmi.
Aight. Thanks.
from wasmi.
Thank you, that sounds great.
I could make a PR for the README to include the proposal and suggest resumables, if you'd like.
from wasmi.
Thank you, that sounds great.
I could make a PR for the README to include the proposal and suggest resumables, if you'd like.
A write-up is probably welcome, though I would prefer to have a discussion item for it in our Wasmi discussions GitHub forums. So we can simply refer people to the write-up. :)
Can we close this issue now? :)
from wasmi.
Related Issues (20)
- Wasmi `v0.32.0-beta.13` seems to have broken linking HOT 13
- CLI: cannot find definition for imported function HOT 4
- Performance regression since `v0.32-beta.16` for `debug` builds with profile overwrites HOT 7
- Optimize `Instance` handling in the `CallStack` HOT 1
- Redundant `local.tee` instruction with overwriting semantics causes miscompilation HOT 13
- Add `Store::call_hook` API HOT 5
- Add way to access unknown custom sections in `Module`
- Implement stable fuel metering HOT 6
- Implement support for `wasi-nn` HOT 1
- Failed to install `wasmi_cli`: `raw mutable pointers are not allowed in statics` (Rust 1.77.1) HOT 4
- How does the executor calculate i32 binary opcodes? HOT 2
- Prepare Wasmi bytecode, translator and executor for tail-call based instruction dispatch
- CI: fuzzing CI seems to not cache the corpus
- Make `CodeMap` lock-free
- Add customizable `wasmi::Engine` limits
- Reconsider proper fuel charging for lazily compiled functions
- Reduce `wasmi::Engine` memory consumption for storing function artifacts HOT 3
- Try to put the Wasmi engine internals into its own crate
- Wasmi v0.32 stable release preparations
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wasmi.