mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
block_util: Avoid reallocation of Vec on push
When using DHAT[1] for analysis the amount heap allocations change from: dhat: Total: 3,186,536 bytes in 41,452 blocks to dhat: Total: 1,059,816 bytes in 34,747 blocks When running against virtio-block; this still more allocations than virtio-pmem but a significant improvement without any cost. [1] https://docs.rs/dhat/latest/dhat/ Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
@@ -156,9 +156,8 @@ impl AsyncIo for RawFileAsync {
|
||||
}
|
||||
|
||||
fn complete(&mut self) -> Vec<(u64, i32)> {
|
||||
let mut completion_list = Vec::new();
|
||||
|
||||
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()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user