All Projects → skyzh → uring-positioned-io

skyzh / uring-positioned-io

Licence: Apache-2.0 license
Async positioned I/O with io_uring.

Programming Languages

rust
11053 projects

uring-positioned-io

Fully asynchronized positioned I/O with io_uring.

Basic Usage

let files = vec![File::open("test.txt").unwrap()];
let context = UringContext::new(files, 256, 1, false).unwrap();
let mut buf = vec![0; 4];
let (_, sz) = context.read(0, 0, &mut buf).await.unwrap();
assert_eq!(&buf[..sz], b"test");

Limitations

Read buffer must be valid until a read is complete. This means that you must poll a read future until completion. You could not abort a read future. Later we may mark read as unsafe.

Benchmark

First, generate benchmark 128 files, with 1GB (262144 * 4K block) size each. Each block is filled with hash(file_id, block_id).

cargo run -p uring_bench --release generate --nf 128 --nb 262144 --dir ~/Work/uring_bench

Then, benchmark with io_uring. Benchmark script will read 4K block and verify it.

RUST_LOG=info cargo run -p uring_bench --release -- read --nf 128 --nb 262144 --dir ~/Work/uring_bench --duration 60 --concurrent 32 --ql 512
RUST_LOG=info cargo run -p uring_bench --release -- read --nf 128 --nb 262144 --dir ~/Work/uring_bench --duration 60 --concurrent 512 --ql 512

Finally, compare io_uring with mmap by benchmarking.

RUST_LOG=info cargo run -p uring_bench --release -- read_mmap --nf 128 --nb 262144 --dir ~/Work/uring_bench --duration 60 --threads 8
RUST_LOG=info cargo run -p uring_bench --release -- read_mmap --nf 128 --nb 262144 --dir ~/Work/uring_bench --duration 60 --threads 32

Benchmark result can be found on my blog.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].