pub struct FileStorageConfig {
pub path: PathBuf,
pub use_mmap: bool,
pub buffer_size: usize,
pub sync_writes: bool,
pub use_locking: bool,
pub temp_dir: Option<String>,
pub mmap_cache_size: usize,
pub mmap_enable_prefault: bool,
pub mmap_enable_hugepages: bool,
}Expand description
Configuration specific to file-based storage.
This configuration includes the storage path and various options for file I/O, memory-mapping, and locking behavior.
§Memory-Mapped Files (mmap)
When use_mmap is enabled, FileStorage uses memory-mapped I/O for reading files,
which can significantly improve performance for large files by:
- Avoiding system call overhead
- Leveraging the OS page cache
- Enabling zero-copy reads
Additional mmap options:
mmap_cache_size: Number of mmap files to keep cachedmmap_enable_prefault: Pre-populate page tables for faster initial accessmmap_enable_hugepages: Use huge pages if available (Linux)
§Example
use laurus::storage::file::FileStorageConfig;
// Basic file storage
let config = FileStorageConfig::new("/data/index");
// High-performance configuration with mmap
let mut config = FileStorageConfig::new("/data/index");
config.use_mmap = true;
config.mmap_enable_prefault = true;
config.buffer_size = 131072; // 128KB for non-mmap operationsFields§
§path: PathBufPath to the storage directory.
use_mmap: boolWhether to use memory-mapped files for reading. When true, files are read using mmap instead of traditional I/O.
buffer_size: usizeBuffer size for traditional I/O operations (bytes).
Default: 65536 (64KB). Used when use_mmap is false.
sync_writes: boolWhether to sync writes immediately to disk. When true, calls fsync after each write for durability.
use_locking: boolWhether to use file locking for concurrency control.
temp_dir: Option<String>Temporary directory for temp files. If None, uses the storage directory.
mmap_cache_size: usizeMaximum number of memory-mapped files to cache.
Only used when use_mmap is true. Default: 100.
mmap_enable_prefault: boolEnable prefaulting for memory-mapped files.
Pre-populates page tables for faster initial access.
Only used when use_mmap is true.
mmap_enable_hugepages: boolEnable huge pages for memory-mapped files if available.
Can improve TLB performance for large files (Linux only).
Only used when use_mmap is true.
Note: This field is currently a placeholder and is not yet used
by the get_mmap() implementation. Setting it has no effect at this time.
Implementations§
Trait Implementations§
Source§impl Clone for FileStorageConfig
impl Clone for FileStorageConfig
Source§fn clone(&self) -> FileStorageConfig
fn clone(&self) -> FileStorageConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for FileStorageConfig
impl RefUnwindSafe for FileStorageConfig
impl Send for FileStorageConfig
impl Sync for FileStorageConfig
impl Unpin for FileStorageConfig
impl UnsafeUnpin for FileStorageConfig
impl UnwindSafe for FileStorageConfig
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.