Skip to content

Commit

Permalink
fix: fix io buffer pool alignment (foyer-rs#724)
Browse files Browse the repository at this point in the history
Signed-off-by: MrCroxx <mrcroxx@outlook.com>
  • Loading branch information
MrCroxx authored Sep 20, 2024
1 parent 474fd2f commit 7ebc971
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion foyer-storage/src/io_buffer_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions foyer-storage/src/large/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 7ebc971

Please sign in to comment.