Description
ApexStore currently reads SSTable data through SstableReader with explicit read() syscalls. MMAP allows the OS to manage disk-to-memory paging transparently, reducing syscall overhead and enabling better cache utilization.
Proposed Implementation
- Add
mmap_read: bool to StorageConfig (default: false for compatibility)
- When enabled, open SSTable files with
memmap2 crate
- Serve read requests directly from the mmap region (zero-copy)
- Use
MADV_RANDOM or MADV_SEQUENTIAL advice depending on access pattern
- Fall back to
pread() for blocks that fail to mmap (e.g., file too large on 32-bit)
Expected Impact
- 20-40% reduction in cold read latency (fewer syscalls)
- Reduced memory pressure (OS manages page cache vs application buffer)
- Faster database restarts (no need to pre-warm cache)
Labels
Description
ApexStore currently reads SSTable data through
SstableReaderwith explicitread()syscalls. MMAP allows the OS to manage disk-to-memory paging transparently, reducing syscall overhead and enabling better cache utilization.Proposed Implementation
mmap_read: booltoStorageConfig(default: false for compatibility)memmap2crateMADV_RANDOMorMADV_SEQUENTIALadvice depending on access patternpread()for blocks that fail to mmap (e.g., file too large on 32-bit)Expected Impact
Labels