How long will it take before wasi-common gets removed? I'm working on migrating a project from Wasmer to Wasmtime. wasi-common has a much closer api to wasmer-wasi than wasmtime-wasi. As such I chose to use wasi-common for now. Can I expect it to stay around for a while or will it be removed soon?
While I don't think anyone has a concrete plan yet it's very much on life support and it's recommended to switch to wasmtime-wasi
. It's effectively a candidate for deletion as soon as anyone finds the motivation/time
The async requirement of wasmtime-wasi is pretty inconvenient. I couldn't easily figure out how to pipe data into stdin and read it out of stdout again.
That'd probably be a good candidate for adding various adapters/types to work with that, we've already got Memory{Input,Output}Pipe
IIRC and we could probably add std::io
-based versions similarly or something similar
With wasi-common I can use ReadPipe::from_shared
and WritePipe::from_shared
wrapping a Arc<RwLock<VecDeque<u8>>>
which is trivial to write to by making a clone of the Arc
and then using synchronous read/write calls that will never block, but wasmtime-wasi requires async streams and then somehow handling the case where Poll::Pending
is returned, but the host program doesn't use async anywhere in the plugin integration.
Yes that's something we can provide an adapter for
it's possible to turn an Arc<RwLock>
and adapt it to the async interfaces required by wasmtime-wasi
For AsyncWrite it was almost trivial to forward to Write. For AsyncRead however the implementation seems to be a lot more involved.
I got something that compiles, but it is infecting a lot more with async than just those adapters. instantiate
and call
both need their async version. I tried wasmtime_wasi::runtime::in_tokio
, but there is a deadlock somewhere. The last wasi call is a write to stdout.
https://github.com/bjorn3/zellij/commit/091ec7fd5db1661bf44d390bd0ce64188e74d42d is what I got right now.
oh I wasn't imagining that the whole embedding would turn async since wasmtime-wasi has a sync mode too
I was thinking that the adapters might only work in sync mode or something like that
Did you try using the sync::add_to_linker? You shouldn’t use in_tokio from outside the wasmtime-wasi crate or child crates such as wasmtime-wasi-http
I can't find any sync variant in wasmtime_wasi::preview1
. I'm trying to prevent adding preview2 support for now in case the migration needs to be rolled back.
Is there a different add_to_linker
that I can use for sync + preview1-only?
yeah sorry i got the name wrong, the sync/async specifier is a suffix now not a mod
That solves the async infection issue. It doesn't solve the deadlock though.
https://github.com/bjorn3/zellij/commit/9f35c9fda1c9d05ba78e90048e9be962d53558a2 is what I have now.
I think that you'll still need to bridge the async-ness in the vecdeque adapters perhaps?
hm no they're always ready
are you able to capture the stack at deadlock time?
There are a lot of threads. I have no clue which one is deadlocking.
on that commit is there a command to run to poke around?
cargo xtask run
It gets stuck at Starting
.
You can exit with ctrl+q and due to the deadlock you have to manually kill the zellij --server
process after exiting the client.
05809cb955d40053f1159030fe88f5b69e48f717 now, right?
Yeah, that is my current version. The only difference with the last commit I linked is a change to CONTRIBUTING.md though.
do you know what to do with:
called `Result::unwrap()` on an `Err` value: Custom { kind: Other, error: "protoc failed: resize.proto:19:12: Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'optional' fields in Proto3, simply remove the 'optional' label, as fields are 'optional' by default.\n" }
You can find the logs at /tmp/zellij-1000/zellij-log/zellij.log
(substitute your own uid if it isn't 1000)
Alex Crichton said:
do you know what to do with:
called `Result::unwrap()` on an `Err` value: Custom { kind: Other, error: "protoc failed: resize.proto:19:12: Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'optional' fields in Proto3, simply remove the 'optional' label, as fields are 'optional' by default.\n" }
I didn't get that error locally. Maybe you have a different protobuf compiler version?
apparently I had some weird install, trying system package manager
I have version libprotoc 3.21.12
as output of protoc --version
.
same now, making more progress
Thread 108 (Thread 0x716e2bc006c0 (LWP 3558238) "server_listener"):
wow you're not kidding
Commenting out most add_plugin!()
calls in zellij-utils/src/consts.rs may help. You need to leave one of them as otherwise no wasm plugin will be loaded and thus the deadlock can't occur.
hm ok you might want to avoid all the async stuff actually
there's a lot of layers of adapters here and my guess is there's some background task which needs to run which isn't runnig
but you don't need any of the background tasks in the firstp lace
so for example instead of implementing Async{Read,Write} instead implementing this trait directly
where those should all have pretty trivial implementations on top of Arc<Mutex<VecDeque<...>>>
e.g. stream
is a clone
and HostOutputStream
is "do the thing"
where Subscribe
is "always ready"
it'll probably be a bit wordier but I think that should help resolve the deadlock
(this is all stuff we should improve in wasmtime-wasi ....)
I can try that.
That fixed it. Thanks!
Last updated: Dec 23 2024 at 13:07 UTC