-
Notifications
You must be signed in to change notification settings - Fork 11
Page manager with buffer pool #169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
🟡 Heimdall Review Status
|
dc1f170
to
b35459b
Compare
} | ||
|
||
/// Retrieves a page from the memory mapped file. | ||
pub fn get(&self, _snapshot_id: SnapshotId, page_id: PageId) -> Result<Page<'_>, PageError> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove unused snapshot_id
|
||
// TODO: Temporarily use LruReplacer as the eviction policy, replace with a better eviction policy | ||
pub(crate) struct CacheEvict { | ||
lru_replacer: LruReplacer<PageId>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A new cache eviction policy will be in the nextPR
.map_err(|_| PageError::InvalidValue)?; | ||
// Use O_DIRECT on Linux for better performance, but not available on macOS | ||
#[cfg(target_os = "linux")] | ||
let flags = libc::O_RDWR | libc::O_CREAT | libc::O_DIRECT; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
O_DIRECT to bypass OS page cache, hence avoid double caching
266f484
to
c820e65
Compare
This PR provides a buffer pool as an alternative to mmap for page management.
Benchmark shows that writing is 3 - 4 times faster than the current mmap. Run example/insert to insert 20 million EOA + storage result:
The current cache eviction is just a proof of concept and is not efficient. Another PR will be raised to provide a better eviction policy.