From a02cd0b849538e4e032582e83456228987f526af Mon Sep 17 00:00:00 2001 From: MrCroxx Date: Fri, 20 Sep 2024 04:17:13 +0000 Subject: [PATCH] fix: fix io buffer pool alignment Signed-off-by: MrCroxx --- foyer-storage/src/io_buffer_pool.rs | 5 ++++- foyer-storage/src/large/batch.rs | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/foyer-storage/src/io_buffer_pool.rs b/foyer-storage/src/io_buffer_pool.rs index 4a136fdf..83e42503 100644 --- a/foyer-storage/src/io_buffer_pool.rs +++ b/foyer-storage/src/io_buffer_pool.rs @@ -14,7 +14,9 @@ use std::collections::VecDeque; -use crate::{IoBuffer, IoBytes}; +use foyer_common::bits; + +use crate::{device::ALIGN, IoBuffer, IoBytes}; pub enum Buffer { IoBuffer(IoBuffer), @@ -41,6 +43,7 @@ pub struct IoBufferPool { impl IoBufferPool { pub fn new(buffer_size: usize, capacity: usize) -> Self { + bits::assert_aligned(ALIGN, buffer_size); Self { capacity, buffer_size, diff --git a/foyer-storage/src/large/batch.rs b/foyer-storage/src/large/batch.rs index ed7e771d..a4e46f87 100644 --- a/foyer-storage/src/large/batch.rs +++ b/foyer-storage/src/large/batch.rs @@ -117,6 +117,7 @@ where S: HashBuilder + Debug, { pub fn new(capacity: usize, region_manager: RegionManager, device: MonitoredDevice, indexer: Indexer) -> Self { + let capacity = bits::align_up(device.align(), capacity); let mut batch = Self { buffer: IoBuffer::new(capacity), len: 0,