Adding a contiguous memory allocator (for large blocks)
Dependencies
- [2]
AI4NKV4JDon't load pages past the end of the file - [3]
IIIOKJTEVersion bump - [4]
KK3SBH4PAdding sanakirja-core-async - [5]
ECPAFJSBadd env_borrow for Txn and MutTxn - [6]
GGEFV4YYSome page splits were not properly handled in deletions - [7]
SYURNHHLAdding the `put_mut` and `set_left_child` methods - [8]
TJ2R4HAZAccessing the root pages (unsafely, of course) - [9]
W2MIZD5BSingle file databases + CRC for the root pages (checking the other pages makes everything very slow) - [10]
PRDUE4YACleanup + published on crates.io - [11]
4Z4GEJTFVersion bump - [12]
OP6SVMODResetting history - [13]
FQ567GAXVersion bumps - [14]
P5NWMJ2HVersion bump - [15]
J7LJZBMESetting reverse cursor to last by default - [16]
DASFQGORDebugging - [17]
WS4ZQM4RDebugging, tests, etc. - [18]
5LSYTRQ6More docs, example, and fixing the free page diagnostic function for mutable transactions - [19]
VRAQTH26Fixing two crashes on corrupted files - [20]
YXKP4AIWNew file locks, with multiple sets of free pages - [21]
2ZRCQBXPVersion bump - [22]
7T2CCH3PFixing a segfault (wrong offset in page_unsized::del) - [23]
OFINGD26implementing prev() on cursors (+ some cleanup) - [24]
77TAHKV4Fixing a logical error (again) in del - [25]
GPP7KJSFVersion bump - [26]
M6PHQUGLfallocate only when necessary - [27]
Z33OHFPAVersion bump - [28]
OHG5NX6KRefactoring, drop and the Check trait - [29]
PUOGOIJ3Debugging, impls and version bump - [30]
BPR2HVMRVersion bump - [31]
E4MD6T3LProofreading and commenting of this crate (massive bug fixes included) - [32]
OHUZ73MKVersions - [33]
WTXLZDYIFixing bus errors on a full disk - [34]
RLVQDUPYFixing a double-free error introduced in 1.2.13 - [35]
DEKK3RUIFixing a bug when splitting unsized pages
Change contents
- replacement in sanakirja-core/Cargo.toml at line 3
version = "1.2.16"version = "1.3.0" - edit in sanakirja/src/environment/muttxn.rs at line 499
}}}/// Allocate many contiguous pages, return the first onefn alloc_contiguous(&mut self, length: u64) -> Result<MutPage, Error> {// Check that length is a multiple of the page size.assert_eq!(length & (PAGE_SIZE as u64 - 1), 0);self.free_owned_pages.sort_by(|a, b| b.cmp(a));self.initial_free.sort_by(|a, b| b.cmp(a));let mut i = self.free_owned_pages.len();let mut ni = 0;let mut j = self.initial_free.len();let mut nj = 0;let mut result = 0u64;let mut current = 0u64;let mut current_p = std::ptr::null_mut();while current + PAGE_SIZE as u64 - result < length {// page allocated, consumed in i, consumed in jlet (m, ic, jc) = if i > 0 && j > 0 {let a = self.free_owned_pages[i - 1];let b = self.initial_free[j - 1];if a < b {i -= 1;(a, 1, 0)} else {j -= 1;(b, 0, 1)}} else if i > 0 {i -= 1;(self.free_owned_pages[i], 1, 0)} else if j > 0 {j -= 1;let p = self.initial_free[j];// Check whether p is available for all txnsif !self.free_for_all(p)? {// Reset the current block, no free page was consumed.ni = 0;nj = 0;current = result;current_p = unsafe { self.env.borrow().find_offset(current)? };continue;}(p, 0, 1)} else if current == result {// No current region, and we've reached the end of the file, just allocate there.let offset = self.length;let data = unsafe { self.env.borrow().find_offset(offset)? };self.length += length;return Ok(MutPage(CowPage { offset, data }));} else if current + PAGE_SIZE as u64 == self.length {// We've reached the end of the file, grow just one last time.self.length += length - (current + PAGE_SIZE as u64 - result);break;} else {unreachable!()};if current > 0 && m == current + PAGE_SIZE as u64 {// We only have to check whether `current` is actually// contiguous in terms of pointers.let next_p = unsafe { self.env.borrow().find_offset(m)? };if next_p as usize == current_p as usize + PAGE_SIZE {ni += ic;nj += jc;} else {// `m` is the first page in a new map, reset the blockresult = m;ni = ic;nj = jc;}current = m;current_p = next_p} else {// Initial regionresult = m;current = m;current_p = unsafe { self.env.borrow().find_offset(m)? };ni = ic;nj = jc; - edit in sanakirja/src/environment/muttxn.rs at line 581
}for offset in self.free_owned_pages.drain(i..i + ni).chain(self.initial_free.drain(j..j + nj)){let data = unsafe { self.env.borrow().find_offset(offset)? };self.occupied_owned_pages.push(MutPage(CowPage { data, offset })) - edit in sanakirja/src/environment/muttxn.rs at line 591
let data = unsafe { self.env.borrow().find_offset(result)? };Ok(MutPage(CowPage {data,offset: result,})) - replacement in sanakirja/src/environment/muttxn.rs at line 716
return Err(Error::Corrupt(off))return Err(Error::Corrupt(off)); - edit in sanakirja/src/environment/mod.rs at line 9
use log::*; - edit in sanakirja/src/environment/mod.rs at line 18
use log::*; - replacement in sanakirja/src/environment/mod.rs at line 177
return Err(Error::VersionMismatch)return Err(Error::VersionMismatch); - replacement in sanakirja/src/environment/mod.rs at line 354
info!("find_offset, i = {:?}/{:?}, extending, offset = {:?}, length0 = {:?}", i, mmaps.len(), offset, length0);info!("find_offset, i = {:?}/{:?}, extending, offset = {:?}, length0 = {:?}",i,mmaps.len(),offset,length0); - edit in sanakirja/src/environment/mod.rs at line 471
- replacement in sanakirja/src/environment/mod.rs at line 472
/// Borrow envpub fn env_borrow(&self) -> &Env {self.env.borrow()}/// Borrow envpub fn env_borrow(&self) -> &Env {self.env.borrow()} - replacement in sanakirja/src/environment/mod.rs at line 573
return Err(Error::Corrupt(off))return Err(Error::Corrupt(off)); - replacement in sanakirja/src/environment/mod.rs at line 646
.ptr.add(self.root * PAGE_SIZE + GLOBAL_HEADER_SIZE + 8 * n)as *mut u64).ptr.add(self.root * PAGE_SIZE + GLOBAL_HEADER_SIZE + 8 * n) as *mut u64) - replacement in sanakirja/Cargo.toml at line 3
version = "1.2.16"version = "1.3.0" - replacement in sanakirja/Cargo.toml at line 32
sanakirja-core = { path = "../sanakirja-core", version = "1.2.16" }sanakirja-core = { path = "../sanakirja-core", version = "1.3.0" } - replacement in Cargo.toml at line 2
members = [ "sanakirja-core", "sanakirja", "sanakirja-core-async" ][5.108848]members = [ "sanakirja-core", "sanakirja", "sanakirja-core-async", "bla" ]