-
Notifications
You must be signed in to change notification settings - Fork 8
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
call fsyncdata on flush #49
Conversation
c2626f4
to
2a053af
Compare
2a053af
to
ecb54de
Compare
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.
Can you check the performance? I would like to get an idea of the impact of fsync on SSD. In particular, do we want to make it optional in the options?
Co-authored-by: Paul Masurel <[email protected]>
I think we want a manual mode for Quickwit because we do: for subrequest in request.subrequests:
mrecordlog.write(subrequest.records) It's unfortunate to have to flush or fsync in the middle of the loop currently. |
hum, currently we offer to flush/fsync either at every write, or at most once every X seconds (which quickwit uses). We may want a 3rd "only flush when asked for", but that seems orthogonal to this pr |
we definitely wants this optional. When flushing every 16k/256k/4m: bench time is +13600%/+3132.9%/+422.11% (i did not run benches with smaller blocks, they were too slow). |
The code has become a tiny bit too flexible and a bit too confusing. (sync and flush are interverted in places) Can we call it #[derive(Copy, Clone, Debug)]
pub enum PersistAction {
/// The buffer will be flushed to the OS, but not necessarily to the disk.
Flush,
/// The buffer will be flushed to the OS, and the OS will be asked to flush
/// it to the disk.
FlushAndFsync,
}
/// We have two type of operations on the mrecordlog.
///
/// Critical records are relatively rare and really need to be persisted:
/// - RecordPosition { queue: &'a str, position: u64 },
/// - DeleteQueue.
///
/// For these operations, we want to always flush and fsync.
///
/// On the other hand,
/// - Truncate
/// - AppendRecords
/// are considered are more frequent and one might want to sacrifice
/// persistence guarantees for performance.
///
/// The `PersistPolicy` defines the trade-off applied for the second kind of
/// operations.
pub enum PersistPolicy {
DoNothing,
Always(PersistAction),
OnDelay(PersistAction),
}
#[derive(Debug)]
enum PersistState {
OnAppend,
OnDelay {
next_sync: Instant,
interval: Duration,
},
OnRequest,
} Also, we are supposed to fsync the parent directory (yeah it is weird) when we create a new file. Suggestion: we could always fsync a file when we close it. |
turns out it also works on directories
superseded by #54 (conflict with main was easier to fix by starting anew) |
fix #48