diff --git a/Cargo.lock b/Cargo.lock index 8b8e86da..082511dd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -96,12 +96,6 @@ dependencies = [ "nom", ] -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - [[package]] name = "cfg-if" version = "1.0.0" @@ -209,7 +203,7 @@ version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "crossbeam-utils", ] @@ -219,7 +213,7 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "crossbeam-epoch", "crossbeam-utils", ] @@ -231,7 +225,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" dependencies = [ "autocfg", - "cfg-if 1.0.0", + "cfg-if", "crossbeam-utils", "memoffset", "scopeguard", @@ -243,7 +237,7 @@ version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", ] [[package]] @@ -312,12 +306,6 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" -[[package]] -name = "iai" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71a816c97c42258aa5834d07590b718b4c9a598944cd39a52dc25b351185d678" - [[package]] name = "indexmap" version = "1.9.3" @@ -346,11 +334,8 @@ name = "io-uring-bench" version = "0.1.0" dependencies = [ "criterion", - "iai", "io-uring", - "iou", "tempfile", - "uring-sys", ] [[package]] @@ -366,18 +351,6 @@ dependencies = [ "tempfile", ] -[[package]] -name = "iou" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22820ec519c7eb16f9ea64316062817963fae77652de6cd8e7655f97bf4fd6dc" -dependencies = [ - "bitflags 1.3.2", - "libc", - "nix", - "uring-sys", -] - [[package]] name = "itertools" version = "0.10.5" @@ -426,7 +399,7 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "winapi", ] @@ -463,18 +436,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" -[[package]] -name = "nix" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83450fe6a6142ddd95fb064b746083fc4ef1705fe81f64a64e1d4b39f54a1055" -dependencies = [ - "bitflags 1.3.2", - "cc", - "cfg-if 0.1.10", - "libc", -] - [[package]] name = "nom" version = "7.1.3" @@ -755,7 +716,7 @@ version = "3.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "fastrand", "redox_syscall", "rustix", @@ -784,16 +745,6 @@ version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" -[[package]] -name = "uring-sys" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a0c460001a5aba8959d84d643a413a709b19871248651f912a264485da3324c" -dependencies = [ - "cc", - "libc", -] - [[package]] name = "walkdir" version = "2.4.0" @@ -810,7 +761,7 @@ version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "wasm-bindgen-macro", ] diff --git a/io-uring-bench/Cargo.toml b/io-uring-bench/Cargo.toml index 046e0daa..18792853 100644 --- a/io-uring-bench/Cargo.toml +++ b/io-uring-bench/Cargo.toml @@ -8,10 +8,7 @@ edition = "2018" [dependencies] io-uring = { path = ".." } -iou = "0.3" -uring-sys = "0.7" criterion = "0.4" -iai = "0.1" tempfile = "3" [[bench]] @@ -23,8 +20,3 @@ harness = false name = "iovec" path = "src/iovec.rs" harness = false - -[[bench]] -name = "iai_new_nop" -path = "src/iai_new_nop.rs" -harness = false diff --git a/io-uring-bench/src/iai_new_nop.rs b/io-uring-bench/src/iai_new_nop.rs deleted file mode 100644 index 8e986212..00000000 --- a/io-uring-bench/src/iai_new_nop.rs +++ /dev/null @@ -1,196 +0,0 @@ -use criterion::black_box; - -const N: usize = 8; -const ITER: usize = 8; - -fn bench_io_uring() { - use io_uring::{opcode, IoUring}; - - let mut io_uring = IoUring::new(N as _).unwrap(); - - for _ in 0..ITER { - let mut sq = io_uring.submission(); - - for i in 0..N { - let nop_e = opcode::Nop::new().build().user_data(black_box(i as _)); - unsafe { - sq.push(&nop_e).ok().unwrap(); - } - } - - drop(sq); - - io_uring.submit_and_wait(N).unwrap(); - - io_uring.completion().map(black_box).for_each(drop); - } -} - -fn bench_io_uring_batch() { - use io_uring::{opcode, IoUring}; - use std::mem; - - let mut io_uring = IoUring::new(N as _).unwrap(); - let sqes = [ - opcode::Nop::new().build().user_data(black_box(0)), - opcode::Nop::new().build().user_data(black_box(1)), - opcode::Nop::new().build().user_data(black_box(2)), - opcode::Nop::new().build().user_data(black_box(3)), - opcode::Nop::new().build().user_data(black_box(4)), - opcode::Nop::new().build().user_data(black_box(5)), - opcode::Nop::new().build().user_data(black_box(6)), - opcode::Nop::new().build().user_data(black_box(7)), - ]; - let mut cqes = [ - mem::MaybeUninit::uninit(), - mem::MaybeUninit::uninit(), - mem::MaybeUninit::uninit(), - mem::MaybeUninit::uninit(), - mem::MaybeUninit::uninit(), - mem::MaybeUninit::uninit(), - mem::MaybeUninit::uninit(), - mem::MaybeUninit::uninit(), - ]; - - for _ in 0..ITER { - unsafe { - io_uring.submission().push_multiple(&sqes).ok().unwrap(); - } - - io_uring.submit_and_wait(N).unwrap(); - - let cqes = io_uring.completion().fill(&mut cqes); - - assert_eq!(cqes.len(), N); - - cqes.iter().map(black_box).for_each(drop); - } -} - -fn bench_iou() { - use iou::IoUring; - - let mut io_uring = IoUring::new(N as _).unwrap(); - - for _ in 0..ITER { - let mut sq = io_uring.sq(); - - for i in 0..N { - unsafe { - let mut sqe = sq.prepare_sqe().unwrap(); - sqe.prep_nop(); - sqe.set_user_data(black_box(i as _)); - } - } - - sq.submit_and_wait(N as _).unwrap(); - - io_uring.cqes().map(black_box).for_each(drop); - } -} - -fn bench_uring_sys() { - use std::{mem, ptr}; - use uring_sys::*; - - let mut io_uring = mem::MaybeUninit::::uninit(); - - unsafe { - if io_uring_queue_init(N as _, io_uring.as_mut_ptr(), 0) != 0 { - panic!() - } - } - - let mut io_uring = unsafe { io_uring.assume_init() }; - - for _ in 0..ITER { - for i in 0..N { - unsafe { - let sqe = io_uring_get_sqe(&mut io_uring); - - if sqe.is_null() { - panic!() - } - - io_uring_prep_nop(sqe); - io_uring_sqe_set_data(sqe, i as _); - } - } - - unsafe { - if io_uring_submit_and_wait(&mut io_uring, N as _) < 0 { - panic!() - } - } - - loop { - unsafe { - let mut cqe = ptr::null_mut(); - io_uring_peek_cqe(&mut io_uring, &mut cqe); - - if cqe.is_null() { - break; - } - - black_box(cqe); - - io_uring_cq_advance(&mut io_uring, 1); - } - } - } -} - -fn bench_uring_sys_batch() { - use std::{mem, ptr}; - use uring_sys::*; - - let mut io_uring = mem::MaybeUninit::::uninit(); - - unsafe { - if io_uring_queue_init(N as _, io_uring.as_mut_ptr(), 0) != 0 { - panic!() - } - } - - let mut io_uring = unsafe { io_uring.assume_init() }; - let mut cqes = [ptr::null_mut(); 8]; - - for _ in 0..ITER { - for i in 0..N { - unsafe { - let sqe = io_uring_get_sqe(&mut io_uring); - - if sqe.is_null() { - panic!() - } - - io_uring_prep_nop(sqe); - io_uring_sqe_set_data(sqe, i as _); - } - } - - unsafe { - if io_uring_submit_and_wait(&mut io_uring, N as _) < 0 { - panic!() - } - } - - unsafe { - if io_uring_peek_batch_cqe(&mut io_uring, cqes.as_mut_ptr(), cqes.len() as _) != 8 { - panic!() - } - - io_uring_cq_advance(&mut io_uring, 8); - } - - cqes.iter().copied().map(black_box).for_each(drop); - } -} - -iai::main!( - bench_io_uring, - bench_io_uring_batch, - bench_iou, - bench_uring_sys, - bench_uring_sys_batch -);