compio-rs/compio
소개
코어당 하나의 스레드를 사용하는 Rust 비동기 런타임으로, IOCP, io_uring, 폴링을 지원합니다.
개발 도구측정된 스타 증가
- in 24h
- 0
- in 7 days
- +7
- in 15 days
- +17
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalCompio
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.
Rust version
Compio doesn't have a minimum supported Rust version (MSRV). It isn't on a stable release rhythm yet, so any release may start using features from the latest stable Rust, and you should expect to need a recent stable toolchain. We might set an MSRV once compio reaches 1.0.
Observability
The console feature makes the runtime emit the tracing spans and events that tokio-console consumes, so compio applications can be inspected with it:
cargo add compio --features console
cargo add console-subscriber
# .cargo/config.toml
#
# `console-subscriber` refuses to run unless the runtime is known to be
# instrumented; this is the escape hatch it provides for runtimes other than
# tokio.
[build]
rustflags = ["--cfg", "console_without_tokio_unstable"]
console_subscriber::init();
compio::runtime::Runtime::new().unwrap().block_on(async {
// ...
});
Then run tokio-console to watch tasks, poll times and waker activity. The console module docs describe what is reported and what is not.
The console example runs an echo server on a dispatcher, so that the console shows the tasks of a thread-per-core application spread over its worker threads, next to tasks that are wrong in the ways it warns about. It passes the cfg on the command line instead:
RUSTFLAGS="--cfg console_without_tokio_unstable" \
cargo run --example console --features console,time,net,dispatcher,sync
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 tokio doesn't expose APIs to control mio, and mio doesn't expose APIs to control IOCP.
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.
관련 프로젝트 살펴보기
불러오는 중…