block_util: Avoid intermediate completion queue allocation

Rather than aggregate the completion list into an intermediate vector
instead adjust the API to provide one completion item at a time.

With DHAT this shows the number of heap allocations has decreased.

Before:

    dhat: Total:     623,852 bytes in 8,157 blocks

After:

    dhat: Total:     380,444 bytes in 3,469 blocks

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford
2023-01-10 14:28:29 +00:00
parent 67ff0d7819
commit ce51755109
8 changed files with 17 additions and 21 deletions

View File

@@ -155,13 +155,10 @@ impl AsyncIo for RawFileAsync {
Ok(())
}
fn complete(&mut self) -> Vec<(u64, i32)> {
let cq = self.io_uring.completion();
let mut completion_list = Vec::with_capacity(cq.len());
for cq_entry in cq {
completion_list.push((cq_entry.user_data(), cq_entry.result()));
}
completion_list
fn next_completed_request(&mut self) -> Option<(u64, i32)> {
self.io_uring
.completion()
.next()
.map(|entry| (entry.user_data(), entry.result()))
}
}