A thread-per-core Rust runtime with IOCP/io_uring/polling inspired by monoio.
Add compio as dependency:
cargo add compio --features macros,fsThen use the high level APIs provided to perform filesystem & network IO:
use compio::{fs::File, io::AsyncReadAtExt};
#[compio::main]
async fn main() {
let file = File::open("Cargo.toml").await.unwrap();
let (read, buffer) = file.read_to_end_at(Vec::with_capacity(1024), 0).await.unwrap();
assert_eq!(read, buffer.len());
let buffer = String::from_utf8(buffer).unwrap();
println!("{}", buffer);
}It's also possible to use the low-level driver (the proactor, without async executor) manually. See driver example.
The name comes from "completion-based IO", and follows the non-existent convention that an async runtime should be named with a suffix "io".
Tokio is a great generic-purpose async runtime. However, it is poll-based, and even uses undocumented APIs on Windows. We would like some new high-level APIs to perform IOCP/io_uring.
compio isn't Tokio-based. This is mainly because mio does not expose any public APIs to control IOCP, and tokio won't expose APIs to control mio before mio reaches 1.0.
Monoio focuses on Linux and io-uring, and fallbacks to mio on other platforms.
Glommio doesn't support Windows.
There are also lots of other great async runtimes. But most of them are (at the moment when compio was created) either poll-based, use io-uring unsoundly, or aren't cross-platform. We hope compio can fill this gap.
There are opportunities to contribute to Compio at any level. It doesn't matter if you are just getting started with Rust or are the most weathered expert, we can use your help. If you have any question about Compio, feel free to join our telegram group. Before contributing, please checkout our contributing guide.