-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
feat(snapshots): refactor snapshot data access #5583
Conversation
This reverts commit b9c51e9.
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.
smol doc nit,
pending @shekhirin
/// File descriptor. Needs to be kept alive as long as the mmap handle. | ||
/// Manages the reading of snapshot data using memory-mapped files. | ||
/// | ||
/// Holds file and mmap descriptors of the data and offsets files of a snapshot. |
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.
offsets files
?
Co-authored-by: Matthias Seitz <[email protected]>
@@ -235,39 +235,61 @@ where | |||
|
|||
// SAFETY: File is read-only and its descriptor is kept alive as long as the mmap handle. | |||
let data_reader = unsafe { memmap2::Mmap::map(&data_file)? }; | |||
let mut obj: Self = bincode::deserialize_from(data_reader.as_ref())?; | |||
let max_row_size: [u8; 8] = | |||
data_reader.as_ref()[0..8].try_into().expect("slice with incorrect length"); |
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.
nit: the error message is not obvious, should it rather be something about missing header?
self.offsets.iter().max().expect("should exist.").leading_zeros() as usize + | ||
7) / | ||
8; | ||
file.write_all(&[bytes_needed as u8])?; |
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.
are we writing max_row_size
here?
reth node
)MmapHandle
becomesDataReader
)This allows the loading of snapshots to be quite faster (~30μs), while allowing us to hold more in memory (if not loading filters)