par_fsync - use VirtualFile

This commit is contained in:
Patrick Insinger
2021-11-11 13:16:34 -08:00
committed by Patrick Insinger
parent 24c8dab86f
commit 191d9d2b74

View File

@@ -1,12 +1,13 @@
use std::{
fs::File,
io,
path::{Path, PathBuf},
sync::atomic::{AtomicUsize, Ordering},
};
use crate::virtual_file::VirtualFile;
fn fsync_path(path: &Path) -> io::Result<()> {
let file = File::open(path)?;
let file = VirtualFile::open(path)?;
file.sync_all()
}
@@ -31,7 +32,6 @@ pub fn par_fsync(paths: &[PathBuf]) -> io::Result<()> {
/// Increasing this limit will
/// - use more memory
/// - increase the cost of spawn/join latency
/// - increase the peak # of file descriptors
const MAX_NUM_THREADS: usize = 64;
let num_threads = paths.len().min(MAX_NUM_THREADS);
let next_path_idx = AtomicUsize::new(0);