From 39d230a8997df5cd972e6a67494f2817f2671ec6 Mon Sep 17 00:00:00 2001 From: PThorpe92 Date: Sun, 3 Aug 2025 15:05:19 -0400 Subject: [PATCH] Add bitmap for tracking pages in arena --- core/io/io_uring.rs | 7 ------- core/storage/buffer_pool.rs | 12 ++---------- core/storage/pager.rs | 4 ++-- 3 files changed, 4 insertions(+), 19 deletions(-) diff --git a/core/io/io_uring.rs b/core/io/io_uring.rs index 183fdda1e..a45f558f1 100644 --- a/core/io/io_uring.rs +++ b/core/io/io_uring.rs @@ -312,13 +312,6 @@ impl WrappedIOUring { }); let mut iov_count = 0; let mut last_end: Option<(*const u8, usize)> = None; - for (idx, buffer) in st - .bufs - .iter() - .enumerate() - .skip(st.current_buffer_idx) - .take(MAX_IOVEC_ENTRIES) - { for buffer in st.bufs.iter().skip(st.current_buffer_idx) { let ptr = buffer.as_ptr(); let len = buffer.len(); diff --git a/core/storage/buffer_pool.rs b/core/storage/buffer_pool.rs index 8d0ad2248..09d18a7db 100644 --- a/core/storage/buffer_pool.rs +++ b/core/storage/buffer_pool.rs @@ -7,7 +7,7 @@ use parking_lot::Mutex; use std::cell::UnsafeCell; use std::ptr::NonNull; use std::sync::atomic::{AtomicU32, AtomicUsize, Ordering}; -use std::sync::{Arc, OnceLock, Weak}; +use std::sync::{Arc, OnceLock}; pub static BUFFER_POOL: OnceLock> = OnceLock::new(); @@ -298,7 +298,7 @@ impl PoolInner { } pub fn free(&self, size: usize, arena_id: u32, page_idx: u32) { - // Check WAL frame arena first + // common case: check WAL frame arena first if let Some(wal_arena) = self.wal_frame_arena.as_ref() { if arena_id == wal_arena.id { let pages = size.div_ceil(wal_arena.page_size); @@ -307,7 +307,6 @@ impl PoolInner { return; } } - // Otherwise use regular arena let arena = self .page_arena @@ -402,13 +401,6 @@ impl Arena { Some(FreeEntry { ptr, first_idx }) } - /// Allocate a contiguous run of `pages`. Returns the first page index. - #[inline] - pub fn alloc_run(&self, pages: u32) -> Option { - let mut bm = self.free_pages.lock(); - bm.alloc_run(pages) - } - pub fn free(&self, page_idx: u32, count: usize) { let mut bm = self.free_pages.lock(); bm.free_run(page_idx, count as u32); diff --git a/core/storage/pager.rs b/core/storage/pager.rs index 74cfa1594..a736a1805 100644 --- a/core/storage/pager.rs +++ b/core/storage/pager.rs @@ -10,8 +10,8 @@ use crate::storage::{ }; use crate::util::IOExt as _; use crate::{ - return_if_io, turso_assert, Completion, Connection, IOResult, LimboError, Result, - TransactionState, WalFrameInfo, + return_if_io, turso_assert, types::WalFrameInfo, Completion, Connection, IOResult, LimboError, + Result, TransactionState, }; use parking_lot::RwLock; use std::cell::{Cell, OnceCell, UnsafeCell};