Skip to content

Commit

Permalink
feat(direct-io): Use take to avoid allocation when releasing ioBuffer (
Browse files Browse the repository at this point in the history
  • Loading branch information
zuston authored Jan 7, 2025
1 parent 546000c commit e3e6100
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/store/alignment/io_buffer_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ impl<'a> RecycledIoBuffer<'a> {
impl Drop for RecycledIoBuffer<'_> {
fn drop(&mut self) {
if let Some(pool) = self.pool_ref {
pool.release(self.internal.clone());
let taked = std::mem::take(&mut self.internal);
pool.release(taked);
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/store/alignment/io_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ impl IoBuffer {
}
}

impl Default for IoBuffer {
fn default() -> Self {
IoBuffer::new(16 * 1024 * 1024)
}
}

impl Deref for IoBuffer {
type Target = BoxA<[u8], &'static AlignedAllocator<ALIGN>>;

Expand Down

0 comments on commit e3e6100

Please sign in to comment.