Shipping as of v0.3.0:
- Fixed-size pages — configurable page size (4 KiB–1 MiB); a versioned 32-byte header with magic, CRC32C, page id, and an LSN slot
- CRC32C integrity — every page is checksummed; a torn, corrupt, or misdirected page is detected on read and returned as a typed error, never silently trusted
- Cross-platform Direct I/O — O_DIRECT (Linux), F_NOCACHE (macOS), FILE_FLAG_NO_BUFFERING (Windows), into buffers aligned to the page size, with a buffered fallback for filesystems that reject it
- Durable on demand —
write_pageplaces bytes,syncmakes them durable (fdatasync / FlushFileBuffers / macOS F_FULLFSYNC) - LRU buffer pool — a bounded frame cache over the file with clock (second-chance) eviction
- Pinning & dirty tracking — a pinned page is never evicted; a dirty page is always flushed before its frame is reused — both verified by property tests and
loommodel checks
Landing next (see dev/ROADMAP.md):
- Page allocation — a free-list / allocator for new and reclaimed page ids
Installation
[]
= "0.3"
Usage
use ;
On a filesystem that rejects O_DIRECT (some overlay and network mounts), open
with PageFileOptions::new().direct_io(false) — same API, same durability via
sync, only the page cache differs.
Through the buffer pool, hot pages stay resident and a fetch returns a pinned frame:
use ;
API Overview
For the complete reference with examples, see docs/API.md.
BufferPool— the bounded page cache with pinning and dirty trackingPageGuard— an RAII pin on a cached page;read/writeborrowsPageFile/PageFileOptions— the durable page store and its open optionsPage— a fixed-size page: header accessors, payload, checksummed framingPageId/Lsn/PageSize— the value typesPageStore— the storage seam the pool sits onPageError— typed integrity and I/O failurescrc32c— the CRC32C checksum, exposed directly
Where It Fits
page-db is the lowest layer of the storage-engine stack. It is built on by:
index-db— B+tree nodes are pages allocated and cached herelock-db— the concurrency-control sibling over the same paged storewal-db— the LSN slot in each page header coordinates with the write-ahead log- heap / B-tree engines — any storage engine that needs durable, cached, fixed-size pages
It depends on no sibling crates — only thiserror (error types) and, on Unix, libc (for O_DIRECT and the macOS durability syscalls) — so it builds and tests standalone today.
Cross-Platform Support
Linux (x86_64, aarch64), macOS (x86_64, Apple Silicon), and Windows (x86_64) are first-class and verified by the CI matrix.
Contributing
See CONTRIBUTING.md and dev/DIRECTIVES.md. Before a PR: cargo fmt --all, cargo clippy --all-targets --all-features -- -D warnings, and cargo test --all-features must be clean.