Skip to content
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

Closed
wants to merge 10 commits into from
Closed

call fsyncdata on flush #49

wants to merge 10 commits into from

Conversation

trinity-1686a
Copy link
Contributor

fix #48

src/rolling/directory.rs Outdated Show resolved Hide resolved
src/rolling/directory.rs Outdated Show resolved Hide resolved
src/rolling/directory.rs Outdated Show resolved Hide resolved
src/rolling/directory.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@fulmicoton fulmicoton left a 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?

@guilload
Copy link
Member

guilload commented Feb 7, 2024

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.

@trinity-1686a
Copy link
Contributor Author

I think we want a manual mode for Quickwit because we do

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

@trinity-1686a
Copy link
Contributor Author

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?

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).
if syncing every 100ms instead of every block of record, the results are less terrible: +92%/+87%/+49%

@fulmicoton
Copy link
Contributor

fulmicoton commented Feb 22, 2024

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 persist as the generic word, and drop the separate SyncPolicy?

#[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.

@trinity-1686a
Copy link
Contributor Author

trinity-1686a commented Mar 1, 2024

superseded by #54 (conflict with main was easier to fix by starting anew)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fsync_data in SyncPolicy?
3 participants