Skip to content

Commit

Permalink
feat: improve hw perfomance
Browse files Browse the repository at this point in the history
  • Loading branch information
fraidev committed Jan 14, 2025
1 parent 4cd4f7d commit 943a4b1
Showing 1 changed file with 11 additions and 1 deletion.
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

0 comments on commit 943a4b1

Please sign in to comment.