mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-02 14:54:23 +01:00
Add bitmap for tracking pages in arena
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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<Arc<BufferPool>> = 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<u32> {
|
||||
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);
|
||||
|
||||
@@ -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};
|
||||
|
||||
Reference in New Issue
Block a user