Replies: 1 comment 7 replies
-
This is not something that has a simple solution. You cannot just provide a |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Dear tokio developers,
It's great to see the features
rt,time,...
are stablized on WASM. However, there is still a gap to use it in our scenario.Background
We are building a WASM-based app engine that runs inside TEE environment (Currently in Intel SGX). Where the wasm host runtime runs in TEE and the guest app is able to access the network via some async IO API. Because the threads in TEE are expensive, we designed the wasm runtime running in a fully async way.
That means, we
impl Future for VmInstance
. So a WASM guest is running viaVmInstance::poll
calls rather than calling a oneshot long blockingfn main()
. This allows it to run much more WASM instances than giving each instance a thread to block in the guest main.The problem
The current tokio runtime/driver for WASM
tokio::runtime::scheduler::current_thread::Spawner
is based onpark/unpark
. This means it would park the current thread while the app is idle. However, since our entire WASM guest is poll based, it would panic to park the current thread in the guest.Idea about the solution
Is it possible to make the tokio runtime poll based rather than parking the current thread?
Or simply open a door to allow the user side to implement custom runtime for tokio? Something like:
The latter is preferred because we can delegate the guest
tokio::time::Sleep
to the hosttokio::time::Sleep
in this way.More info
We have already successfully run some hyper-based HTTP server with our tiny custom async runtime and custom TcpSteam in the WASM guest. However, there are lot's of crates use
tokio::spawn
andtokio::time
, we have to modify them to usesidevm::spwan
andsidevm::time
to run in our WASM guest.Beta Was this translation helpful? Give feedback.
All reactions