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

feat: improve hw perfomance #4320

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion crates/fluvio-storage/src/checkpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ use std::io::Cursor;
use std::io::Error as IoError;
use std::io::ErrorKind;
use std::io::SeekFrom;
use std::os::fd::AsRawFd;
use std::os::fd::FromRawFd;
use std::path::PathBuf;
use std::sync::Arc;

Expand Down Expand Up @@ -72,6 +74,15 @@ pub struct CheckPoint<T> {
file: File,
}

impl<Offset> Drop for CheckPoint<Offset> {
fn drop(&mut self) {
let raw_fd = self.file.as_raw_fd();
let std_file = unsafe { std::fs::File::from_raw_fd(raw_fd) };
std_file.sync_all().expect("sync checkpoint");
std::mem::forget(std_file);
}
}

impl<T> CheckPoint<T>
where
T: Display + ReadToBuf + Clone + Sized + 'static,
Expand Down Expand Up @@ -151,7 +162,6 @@ where
self.offset = pos;
self.offset.write_to(&mut contents);
self.file.write_all(&contents).await?;
self.file.sync_all().await?;
Ok(())
}
}
Expand Down
Loading