Skip to content

compio-rs/compio


Compio

MIT licensed crates.io docs.rs Check Test Telegram

A thread-per-core Rust runtime with IOCP/io_uring/polling inspired by monoio.

Quick start

Add compio as dependency:

cargo add compio --features macros,fs

Then 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.

Why the name?

The name comes from "completion-based IO", and follows the non-existent convention that an async runtime should be named with a suffix "io".

Comparison with other runtimes

Tokio

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

Monoio focuses on Linux and io-uring, and fallbacks to mio on other platforms.

Glommio

Glommio doesn't support Windows.

Others

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.

Contributing

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.

About

A thread-per-core Rust runtime with IOCP/io_uring/polling.

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Contributors 34

Languages