refactor(tvix/castore/fs): set sane default option flags
Sets some sane default caching options and flags for tvix_castore::fs::TvixStoreFs, greatly reducing latency on cache hits. See: https://man7.org/linux/man-pages/man4/fuse.4.html See: https://docs.rs/fuse-backend-rs/latest/fuse_backend_rs/abi/fuse_abi/struct.FsOptions.html Co-Authored-By: Florian Klink <flokli@flokli.de> Change-Id: Ie105249fc92f56604e7c337d5983e4038b775f42 Reviewed-on: https://cl.tvl.fyi/c/depot/+/13002 Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
This commit is contained in:
parent
e53adc75bf
commit
fa654a5dc9
1 changed files with 20 additions and 12 deletions
|
|
@ -322,7 +322,20 @@ where
|
||||||
type Inode = u64;
|
type Inode = u64;
|
||||||
|
|
||||||
fn init(&self, _capable: FsOptions) -> io::Result<FsOptions> {
|
fn init(&self, _capable: FsOptions) -> io::Result<FsOptions> {
|
||||||
Ok(FsOptions::empty())
|
let mut opts = FsOptions::empty();
|
||||||
|
|
||||||
|
// the filesystem supports readdirplus
|
||||||
|
opts |= FsOptions::DO_READDIRPLUS;
|
||||||
|
// issue both readdir and readdirplus depending on the information expected to be required
|
||||||
|
opts |= FsOptions::READDIRPLUS_AUTO;
|
||||||
|
// allow more than one pending read request per file-handle at any time
|
||||||
|
opts |= FsOptions::ASYNC_READ;
|
||||||
|
// allow concurrent lookup() and readdir() requests for the same directory
|
||||||
|
opts |= FsOptions::PARALLEL_DIROPS;
|
||||||
|
// have the kernel cache symlink contents
|
||||||
|
opts |= FsOptions::CACHE_SYMLINKS;
|
||||||
|
|
||||||
|
Ok(opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip_all, fields(rq.inode = inode))]
|
#[tracing::instrument(skip_all, fields(rq.inode = inode))]
|
||||||
|
|
@ -436,13 +449,11 @@ where
|
||||||
.write()
|
.write()
|
||||||
.insert(dh, (Span::current(), Arc::new(Mutex::new(rx))));
|
.insert(dh, (Span::current(), Arc::new(Mutex::new(rx))));
|
||||||
|
|
||||||
return Ok((
|
return Ok((Some(dh), OpenOptions::NONSEEKABLE));
|
||||||
Some(dh),
|
|
||||||
fuse_backend_rs::api::filesystem::OpenOptions::empty(), // TODO: non-seekable
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok((None, OpenOptions::empty()))
|
// allow caching this directory contents, don't invalidate on open
|
||||||
|
Ok((None, OpenOptions::CACHE_DIR | OpenOptions::KEEP_CACHE))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip_all, fields(rq.inode = inode, rq.handle = handle, rq.offset = offset), parent = self.dir_handles.read().get(&handle).and_then(|x| x.0.id()))]
|
#[tracing::instrument(skip_all, fields(rq.inode = inode, rq.handle = handle, rq.offset = offset), parent = self.dir_handles.read().get(&handle).and_then(|x| x.0.id()))]
|
||||||
|
|
@ -653,11 +664,7 @@ where
|
||||||
inode: Self::Inode,
|
inode: Self::Inode,
|
||||||
_flags: u32,
|
_flags: u32,
|
||||||
_fuse_flags: u32,
|
_fuse_flags: u32,
|
||||||
) -> io::Result<(
|
) -> io::Result<(Option<Self::Handle>, OpenOptions, Option<u32>)> {
|
||||||
Option<Self::Handle>,
|
|
||||||
fuse_backend_rs::api::filesystem::OpenOptions,
|
|
||||||
Option<u32>,
|
|
||||||
)> {
|
|
||||||
if inode == ROOT_ID {
|
if inode == ROOT_ID {
|
||||||
return Err(io::Error::from_raw_os_error(libc::ENOSYS));
|
return Err(io::Error::from_raw_os_error(libc::ENOSYS));
|
||||||
}
|
}
|
||||||
|
|
@ -699,7 +706,8 @@ where
|
||||||
|
|
||||||
Ok((
|
Ok((
|
||||||
Some(fh),
|
Some(fh),
|
||||||
fuse_backend_rs::api::filesystem::OpenOptions::empty(),
|
// Don't invalidate the data cache on open.
|
||||||
|
OpenOptions::KEEP_CACHE,
|
||||||
None,
|
None,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue