diff --git a/core/io/io_uring.rs b/core/io/io_uring.rs index b2afeb652..ff0c7c793 100644 --- a/core/io/io_uring.rs +++ b/core/io/io_uring.rs @@ -105,6 +105,10 @@ impl UringIO { }; // we only ever have 2 files open at a time for the moment ring.submitter().register_files_sparse(FILES)?; + // RL_MEMLOCK cap is typically 8MB, the current design is to have one large arena + // registered at startup and therefore we can simply use the zero index, falling back + // to similar logic as the existing buffer pool for cases where it is over capacity. + ring.submitter().register_buffers_sparse(1)?; let inner = InnerUringIO { ring: WrappedIOUring { ring, @@ -460,6 +464,26 @@ impl IO for UringIO { fn get_memory_io(&self) -> Arc { Arc::new(MemoryIO::new()) } + + fn register_fixed_buffer(&self, ptr: std::ptr::NonNull, len: usize) -> Result<()> { + turso_assert!( + len % 512 == 0, + "fixed buffer length must be logical block aligned" + ); + let inner = self.inner.borrow_mut(); + let default_id = 0; + unsafe { + inner.ring.ring.submitter().register_buffers_update( + default_id, + &[libc::iovec { + iov_base: ptr.as_ptr() as *mut libc::c_void, + iov_len: len, + }], + None, + )? + }; + Ok(()) + } } impl Clock for UringIO { diff --git a/core/io/mod.rs b/core/io/mod.rs index 8560216e8..a822cf832 100644 --- a/core/io/mod.rs +++ b/core/io/mod.rs @@ -2,6 +2,7 @@ use crate::Result; use bitflags::bitflags; use cfg_block::cfg_block; use std::fmt; +use std::ptr::NonNull; use std::sync::Arc; use std::{ cell::{Cell, Ref, RefCell, RefMut}, @@ -89,6 +90,12 @@ pub trait IO: Clock + Send + Sync { fn generate_random_number(&self) -> i64; fn get_memory_io(&self) -> Arc; + + fn register_fixed_buffer(&self, _ptr: NonNull, _len: usize) -> Result<()> { + Err(crate::LimboError::InternalError( + "unsupported operation".to_string(), + )) + } } pub type Complete = dyn Fn(Arc>, i32);