Skip to content

Why RaftEngine fdatasync so fast? #317

Answered by tabokie
Neyzoter asked this question in Q&A
Discussion options

You must be logged in to vote

A few reasons I can think of right now:

  • We use fallocate to extend file in advance:

if self.capacity < new_written {
let _t = StopWatch::new(&*LOG_ALLOCATE_DURATION_HISTOGRAM);
let alloc = std::cmp::min(
FILE_ALLOCATE_SIZE,
target_size_hint.saturating_sub(self.capacity),
);
let alloc = std::cmp::max(new_written - self.capacity, alloc);
if let Err(e) = self.writer.allocate(self.capacity, alloc) {
warn!("log file allocation failed: {e}");
}
self.capacity += alloc;
}

  • We use fdatasync whereas std::File::sync_all uses fsync.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by Neyzoter
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants