diff --git a/Cargo.lock b/Cargo.lock index d26da84a6..986baa6fe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1735,6 +1735,8 @@ dependencies = [ "notify", "rand 0.8.5", "rand_chacha 0.3.1", + "regex", + "regex-syntax", "serde", "serde_json", "tempfile", diff --git a/core/io/io_uring.rs b/core/io/io_uring.rs index 1598debfa..eef5e523d 100644 --- a/core/io/io_uring.rs +++ b/core/io/io_uring.rs @@ -4,7 +4,6 @@ use log::{debug, trace}; use rustix::fs::{self, FlockOperation, OFlags}; use rustix::io_uring::iovec; use std::cell::RefCell; -use std::collections::HashMap; use std::fmt; use std::io::ErrorKind; use std::os::fd::AsFd; @@ -40,7 +39,7 @@ pub struct UringIO { struct WrappedIOUring { ring: io_uring::IoUring, pending_ops: usize, - pub pending: HashMap>, + pub pending: [Option>; MAX_IOVECS as usize + 1], key: u64, } @@ -63,7 +62,7 @@ impl UringIO { ring: WrappedIOUring { ring, pending_ops: 0, - pending: HashMap::new(), + pending: [const { None }; MAX_IOVECS as usize + 1], key: 0, }, iovecs: [iovec { @@ -92,7 +91,7 @@ impl InnerUringIO { impl WrappedIOUring { fn submit_entry(&mut self, entry: &io_uring::squeue::Entry, c: Rc) { trace!("submit_entry({:?})", entry); - self.pending.insert(entry.get_user_data(), c); + self.pending[entry.get_user_data() as usize] = Some(c); unsafe { self.ring .submission() @@ -124,6 +123,11 @@ impl WrappedIOUring { fn get_key(&mut self) -> u64 { self.key += 1; + if self.key == MAX_IOVECS as u64 { + let key = self.key; + self.key = 0; + return key; + } self.key } } @@ -175,10 +179,11 @@ impl IO for UringIO { ))); } { - let c = ring.pending.get(&cqe.user_data()).unwrap().clone(); - c.complete(cqe.result()); + if let Some(c) = ring.pending[cqe.user_data() as usize].as_ref() { + c.complete(cqe.result()); + } } - ring.pending.remove(&cqe.user_data()); + ring.pending[cqe.user_data() as usize] = None; } Ok(()) }