mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-05-11 14:41:16 -07:00
global: perf + resource imprv
This commit is contained in:
@@ -22,6 +22,10 @@ where
|
||||
{
|
||||
const SIZE_OF_T: usize = size_of::<T>();
|
||||
|
||||
#[inline]
|
||||
fn unwrap_read(&self, index: I, mmap: &Mmap) -> T {
|
||||
self.read(index, mmap).unwrap().unwrap()
|
||||
}
|
||||
#[inline]
|
||||
fn read(&self, index: I, mmap: &Mmap) -> Result<Option<T>> {
|
||||
self.read_(index.to_usize()?, mmap)
|
||||
|
||||
@@ -120,12 +120,12 @@ where
|
||||
zstd::encode_all(bytes.as_slice(), DEFAULT_COMPRESSION_LEVEL).unwrap()
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
fn index_to_page_index(index: usize) -> usize {
|
||||
index / Self::PER_PAGE
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
fn page_index_to_index(page_index: usize) -> usize {
|
||||
page_index * Self::PER_PAGE
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ use crate::{
|
||||
|
||||
const ONE_KIB: usize = 1024;
|
||||
const ONE_MIB: usize = ONE_KIB * ONE_KIB;
|
||||
const MAX_CACHE_SIZE: usize = 210 * ONE_MIB;
|
||||
const MAX_CACHE_SIZE: usize = 256 * ONE_MIB;
|
||||
const DCA_AMOUNT: Dollars = Dollars::mint(100.0);
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
||||
@@ -29,6 +29,11 @@ where
|
||||
))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn unwrap_read(&self, index: I, mmap: &Mmap) -> T {
|
||||
self.0.unwrap_read(index, mmap)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn get_or_read(&self, index: I, mmap: &Mmap) -> Result<Option<Cow<T>>> {
|
||||
self.0.get_or_read(index, mmap)
|
||||
|
||||
Reference in New Issue
Block a user