-
Notifications
You must be signed in to change notification settings - Fork 88
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
Optimize log file format for faster recovery #83
Conversation
The new log file format can be found in annotation in `LogBatch::encode_to_bytes`. What's changed? + Optimize log file format for faster recovery. + Refine `EntryIndex` fields in memtable. TODO: + [ ] There is a [PLEASE REVIEW] todo. + [ ] Optimize `read_file` for the new log format. Signed-off-by: MrCroxx <mrcroxx@outlook.com>
@tabokie I found that |
Signed-off-by: MrCroxx <mrcroxx@outlook.com>
Signed-off-by: MrCroxx <mrcroxx@outlook.com>
Instead of reading the whole file, recovery now just read the needed parts of the log file, which saves recovery time. Whats changed? + `LogBatchFileReader`: yeild recovered `LogBatch` from log file, which interally maintains a buffer. + Move common file operation functions from `crate::file_pipe_log` to `crate::util` + All tests passed. Signed-off-by: MrCroxx <mrcroxx@outlook.com>
Signed-off-by: MrCroxx <mrcroxx@outlook.com>
Signed-off-by: MrCroxx <mrcroxx@outlook.com>
Signed-off-by: MrCroxx <mrcroxx@outlook.com>
Only write the first index of a `LogItem::Entries`, for the entries it carries are always continuous. Signed-off-by: MrCroxx <mrcroxx@outlook.com>
Signed-off-by: MrCroxx <mrcroxx@outlook.com>
Signed-off-by: MrCroxx <mrcroxx@outlook.com>
Signed-off-by: MrCroxx <mrcroxx@outlook.com>
Signed-off-by: MrCroxx <mrcroxx@outlook.com>
Signed-off-by: MrCroxx <mrcroxx@outlook.com>
Signed-off-by: MrCroxx <mrcroxx@outlook.com>
+ Add bench `bench_recovery`. + Add failpoint in `open` to disable page cache when benching recovery. Signed-off-by: MrCroxx <mrcroxx@outlook.com>
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.
Good work, let's see some results! BTW You can put the benchmark into a separate PR.
Signed-off-by: MrCroxx <mrcroxx@outlook.com>
Signed-off-by: MrCroxx <mrcroxx@outlook.com>
6d105d4
to
a3d7f67
Compare
/rebuild |
src/file_pipe_log.rs
Outdated
let mut offset = (FILE_MAGIC_HEADER.len() + Version::len()) as u64; | ||
debug!("recover from log file {:?}:{:?}", queue, file_id); | ||
let fd = self.get_queue(queue).get_fd(file_id)?; | ||
let mut reader = LogBatchFileReader::new( |
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.
How about we implement this logic in recover_queue
, so to reuse LogBatchFileReader
and avoid buffering log batches.
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.
That's a good idea. But now some function like get_queue
is only implemented for FilePipeLog
, but recover_queue
is implemented for the trait PepeLog
. Is that fine that we implement a recover_queue
only for FilePipeLog
version?
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.
Indeed, ideally we shouldn't expose log file. Maybe we could replace read_file_into_log_batch
with replay_log_batch
, which takes in a closure Fn(LogBatch)
.
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.
In the next pr I'll implement parallel recovery. I'm not sure if the modification is good for it. What about modify it in the next pr or a seperate pr?
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.
Actually I have a big PR coming up tomorrow, and will fix this issue there.
Signed-off-by: MrCroxx <mrcroxx@outlook.com>
Signed-off-by: MrCroxx <mrcroxx@outlook.com>
Signed-off-by: MrCroxx <mrcroxx@outlook.com>
Previously, `LogBatch` is partially filled (only entries_index needs to be recovered), which is unreasonable. This commit seperate entries from itmes, and add structs to hold them. Signed-off-by: MrCroxx <mrcroxx@outlook.com>
Signed-off-by: MrCroxx <mrcroxx@outlook.com>
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.
Code changes look good overall, still needs some benchmarks to evaluate the regression of write performance and IO usage.
Signed-off-by: MrCroxx <mrcroxx@outlook.com>
Signed-off-by: MrCroxx <mrcroxx@outlook.com>
Signed-off-by: MrCroxx <mrcroxx@outlook.com>
Signed-off-by: MrCroxx <mrcroxx@outlook.com>
Signed-off-by: MrCroxx <mrcroxx@outlook.com>
Benchmark (recovery): configs:
env: slow ssd, fadvise - DONTNEED has been called before reads to disable page cache.
|
Benchmark (stress): old:
new:
|
@tabokie Is this pr ready to merge? |
Signed-off-by: MrCroxx <mrcroxx@outlook.com>
Benchmark (recovery, limited by batch count): configs:
env: slow ssd, fadvise - DONTNEED has been called before reads to disable page cache.
|
The new log file format can be found in annotation in `LogBatch::encode_to_bytes`. What's changed? + Optimize log file format for faster recovery. + Refine `EntryIndex` fields in memtable. Signed-off-by: MrCroxx <mrcroxx@outlook.com>
The new log file format can be found in annotation in `LogBatch::encode_to_bytes`. What's changed? + Optimize log file format for faster recovery. + Refine `EntryIndex` fields in memtable. Signed-off-by: MrCroxx <mrcroxx@outlook.com> Signed-off-by: tabokie <xy.tao@outlook.com>
The new log file format can be found in annotation in `LogBatch::encode_to_bytes`. What's changed? + Optimize log file format for faster recovery. + Refine `EntryIndex` fields in memtable. Signed-off-by: MrCroxx <mrcroxx@outlook.com>
The new log file format can be found in annotation in
LogBatch::encode_to_bytes
.What's changed?
EntryIndex
fields in memtable.TODO:
read_file
for the new log format.Signed-off-by: MrCroxx mrcroxx@outlook.com