Skip to content
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

Async IO, Mio support #1043

Open
koraa opened this issue Jan 27, 2024 · 5 comments
Open

Async IO, Mio support #1043

koraa opened this issue Jan 27, 2024 · 5 comments

Comments

@koraa
Copy link

koraa commented Jan 27, 2024

Thank you for building hermit; I hope this will become a conerstone of rust infrastructure soon!

At Rosenpass (post quantum security for WireGuard in Rust) we are currently exploring using broker based security sandboxing. As part of this project we are trying to add experimental support for running significant parts of the Rosenpass deployment inside Hermit OS.

The core rosenpass process uses mio to handle IO operations to enable the use of async io. We are considering eventually migrating to tokio.

Building hermit-rs-template with --target x86_64-unknown-hermit and a dependency on mio without non-default features yields a successful build. Adding the net feature yields a whole bunch of compile time errors (log).

Is using mio expected to work?

diff --git a/Cargo.toml b/Cargo.toml
index 452bbdc..240333f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -4,4 +4,7 @@ version = "0.1.0"
 edition = "2021"

 [target.'cfg(target_os = "hermit")'.dependencies]
-hermit = "0.8"
+hermit = { version = "0.8", features = ["pci", "pci-ids", "acpi", "fsgsbase", "tcp", "rtl8139"]}
+
+[dependencies]
+mio = { version = "0.8.10", features = ["net"] }

Errors (excerpt)

   Compiling mio v0.8.10
error[E0425]: cannot find value `listener` in this scope
  --> /home/karo/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.10/src/net/tcp/listener.rs:74:24
   |
74 |         set_reuseaddr(&listener.inner, true)?;
   |                        ^^^^^^^^ help: a function with a similar name exists: `listen`
   |
  ::: /home/karo/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.10/src/sys/shell/tcp.rs:20:1
   |
20 | pub(crate) fn listen(_: &net::TcpListener, _: u32) -> io::Result<()> {
   | -------------------------------------------------------------------- similarly named function `listen` defined here

error[E0425]: cannot find value `listener` in this scope
  --> /home/karo/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.10/src/net/tcp/listener.rs:76:15
   |
76 |         bind(&listener.inner, addr)?;
   |               ^^^^^^^^ help: a function with a similar name exists: `listen`
   |
  ::: /home/karo/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.10/src/sys/shell/tcp.rs:20:1
   |
20 | pub(crate) fn listen(_: &net::TcpListener, _: u32) -> io::Result<()> {
   | -------------------------------------------------------------------- similarly named function `listen` defined here
@koraa koraa changed the title Async IO: Mio support Async IO, Mio support Jan 27, 2024
koraa added a commit to rosenpass/rosenpass that referenced this issue Jan 27, 2024
A whole bunch of close-to-the-metal crates are yielding compiler errors
upon compilation with --target x86_64-unknown-hermit. MIO is not.

Using hermit might necessitate relying on threads for IO instead of
using MIO.

hermit-os/kernel#1043
@mkroening
Copy link
Member

We are working on async support for userspace. :)

See also smol-rs/polling#177

@koraa
Copy link
Author

koraa commented Jan 29, 2024

We are working on async support for userspace. :)

See also smol-rs/polling#177

That is wonderful, thank you :)

So we'd probably have to mygrate to smol-rs/polling to make use of that?

@mkroening
Copy link
Member

So we'd probably have to mygrate to smol-rs/polling to make use of that?

No, we want to support Mio too. We are currently at the stage of needing to implement the kernel primitives, but are happy to support multiple different user space crates for async I/O.

@koraa
Copy link
Author

koraa commented Jan 29, 2024

So we'd probably have to mygrate to smol-rs/polling to make use of that?

No, we want to support Mio too. We are currently at the stage of needing to implement the kernel primitives, but are happy to support multiple different user space crates for async I/O.

Sounds great, thank you for that work! Then we will try again once that lands.

@mkroening
Copy link
Member

@stlankes just made a lot of progress towards async I/O on Hermit by adding poll support in #1046. 🥳

@mkroening mkroening pinned this issue May 2, 2024
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

No branches or pull requests

2 participants