pub struct DiskConfig {
pub root: PathBuf,
pub max_bytes: u64,
pub shard_chars: usize,
pub queue_capacity: usize,
pub writer_threads: usize,
pub reader_threads: usize,
pub prefetch_capacity: usize,
pub reserve_bytes: u64,
pub free_space_ttl: Duration,
pub free_space_probe: FreeSpaceProbe,
}Expand description
How the store is sized, laid out, and how much writing it will do off the calling thread.
Fields§
§root: PathBufDirectory the store owns. Created if absent.
max_bytes: u64Byte budget for blocks the store is accounting for. Eviction keeps the store at or under this.
shard_chars: usizeHex characters of the hash used as the shard subdirectory name. 2 gives 256 shards, which keeps directory sizes sane well past a million blocks.
queue_capacity: usizeWrites that may be waiting for a writer thread at once. When it
is full, DiskKvStore::put writes on the calling thread
instead of dropping the block – backpressure, not loss.
writer_threads: usizeBackground writer threads. 0 is legitimate and means every
write happens on the thread that asked for it.
reader_threads: usizeBackground reader threads, serving prefetches and any demand
read that does not want to block its own thread. 0 means every
read happens on the thread that asked for it, and a prefetch is
a no-op.
prefetch_capacity: usizeBlocks that may sit in the prefetch staging area at once. A prefetch is a hint, so this is a hard refusal rather than backpressure: reading ahead must never be the thing that runs the process out of memory.
reserve_bytes: u64Bytes to leave free on the filesystem. The store evicts to stay
this far away from a full disk, rather than letting ENOSPC be
the mechanism that tells it to stop.
free_space_ttl: DurationHow long a free-space reading is trusted before it is taken again.
free_space_probe: FreeSpaceProbeHow free space is measured. Defaults to statvfs on unix, and
to “cannot tell” elsewhere.
Implementations§
Source§impl DiskConfig
impl DiskConfig
pub fn new(root: impl Into<PathBuf>) -> Self
pub fn with_max_bytes(self, max_bytes: u64) -> Self
pub fn with_shard_chars(self, shard_chars: usize) -> Self
pub fn with_queue_capacity(self, queue_capacity: usize) -> Self
pub fn with_writer_threads(self, writer_threads: usize) -> Self
pub fn with_reader_threads(self, reader_threads: usize) -> Self
pub fn with_prefetch_capacity(self, prefetch_capacity: usize) -> Self
pub fn with_reserve_bytes(self, reserve_bytes: u64) -> Self
pub fn with_free_space_ttl(self, free_space_ttl: Duration) -> Self
pub fn with_free_space_probe(self, probe: FreeSpaceProbe) -> Self
Trait Implementations§
Source§impl Clone for DiskConfig
impl Clone for DiskConfig
Source§fn clone(&self) -> DiskConfig
fn clone(&self) -> DiskConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for DiskConfig
impl !UnwindSafe for DiskConfig
impl Freeze for DiskConfig
impl Send for DiskConfig
impl Sync for DiskConfig
impl Unpin for DiskConfig
impl UnsafeUnpin for DiskConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more