pub struct Config {
pub path: PathBuf,
pub block_size: u32,
pub block_cache: Arc<BlockCache>,
pub max_memtable_size: u32,
pub level_count: u8,
pub level_ratio: u8,
pub flush_threads: u8,
pub fsync_ms: Option<usize>,
/* private fields */
}
Expand description
Tree configuration
Fields§
§path: PathBuf
Folder path
block_size: u32
Block size of data and index blocks
block_cache: Arc<BlockCache>
Block cache
max_memtable_size: u32
Maximum size in bytes of the write buffer
level_count: u8
Amount of levels of the LSM tree (depth of tree)
level_ratio: u8
Size ratio between levels of the LSM tree (a.k.a fanout, growth rate).
This is the exponential growth of the from one level to the next
A level target size is: max_memtable_size * level_ratio.pow(#level + 1)
flush_threads: u8
Maximum amount of concurrent flush threads
fsync_ms: Option<usize>
Starts a thread that will periodically fsync the journals for durability
Implementations§
source§impl Config
impl Config
sourcepub fn fsync_ms(self, ms: Option<usize>) -> Self
pub fn fsync_ms(self, ms: Option<usize>) -> Self
Starts a thread that will periodically fsync the journal for durability.
That means in case of a fatal crash (not proper unwind) at most the last ms
of data may be lost.
Without fsyncing, your data is at the mercy of your operating system’s syncing logic.
If you want to make sure a write is definitely durable, call Tree::flush
manually after writing.
Flushing after every write has dramatic performance implications (100x-1000x slower for SSDs).
Even when disabled, the tree will always try to fsync when it is being dropped.
Defaults to 1 second.
Panics
Panics if ms is below 100.
sourcepub fn flush_threads(self, count: u8) -> Self
pub fn flush_threads(self, count: u8) -> Self
Maximum amount of concurrent flush threads.
You may want to increase this the more CPU cores you have.
Defaults to 4.
Panics
Panics if count is 0.
sourcepub fn level_count(self, n: u8) -> Self
pub fn level_count(self, n: u8) -> Self
Sets the amount of levels of the LSM tree (depth of tree).
Defaults to 7, like LevelDB
and RocksDB
.
Panics
Panics if n
is 0.
sourcepub fn level_ratio(self, n: u8) -> Self
pub fn level_ratio(self, n: u8) -> Self
Sets the size ratio between levels of the LSM tree (a.k.a. fanout, growth rate).
Defaults to 10.
Panics
Panics if n
is less than 2.
sourcepub fn max_memtable_size(self, bytes: u32) -> Self
pub fn max_memtable_size(self, bytes: u32) -> Self
Sets the maximum memtable size.
Defaults to 16 MiB.
sourcepub fn block_size(self, block_size: u32) -> Self
pub fn block_size(self, block_size: u32) -> Self
Sets the block size.
Defaults to 4 KiB (4096 bytes).
Panics
Panics if the block size is smaller than 1 KiB (1024 bytes).
sourcepub fn block_cache(self, block_cache: Arc<BlockCache>) -> Self
pub fn block_cache(self, block_cache: Arc<BlockCache>) -> Self
Sets the block cache.
You can create a global BlockCache
and share it between multiple
trees to cap global cache memory usage.
Defaults to a block cache with 16 MiB of capacity per tree.
sourcepub fn compaction_strategy(
self,
strategy: Arc<dyn CompactionStrategy + Send + Sync>
) -> Self
pub fn compaction_strategy( self, strategy: Arc<dyn CompactionStrategy + Send + Sync> ) -> Self
Sets the compaction strategy to use.
Defaults to compaction::Levelled