mirror of
https://github.com/neondatabase/neon.git
synced 2026-06-03 13:30:38 +00:00
incorporate findings from research
This commit is contained in:
@@ -88,7 +88,7 @@ impl EphemeralFile {
|
||||
gate.enter()?,
|
||||
);
|
||||
|
||||
file.fallocate_keep_size(0, 1 * 1024 * 1024 * 1024, ctx)
|
||||
file.fallocate(0, 1 * 1024 * 1024 * 1024, ctx)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ pub async fn download_layer_file<'a>(
|
||||
64 * 1024 /* TODO this is the max roundtup size by the buffered writer set_len_then_truncate */
|
||||
|
||||
)) {
|
||||
temp_file.fallocate_keep_size(
|
||||
temp_file.fallocate(
|
||||
0,
|
||||
file_size,
|
||||
ctx,
|
||||
|
||||
@@ -440,7 +440,7 @@ impl DeltaLayerWriterInner {
|
||||
gate.enter()?,
|
||||
);
|
||||
|
||||
file.fallocate_keep_size(0, 1 * 1024 * 1024 * 1024, ctx)
|
||||
file.fallocate(0, 1 * 1024 * 1024 * 1024, ctx)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
|
||||
@@ -806,7 +806,7 @@ impl ImageLayerWriterInner {
|
||||
gate.enter()?,
|
||||
);
|
||||
|
||||
file.fallocate_keep_size(0, 1 * 1024 * 1024 * 1024, ctx)
|
||||
file.fallocate(0, 1 * 1024 * 1024 * 1024, ctx)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
|
||||
@@ -161,13 +161,13 @@ impl VirtualFile {
|
||||
self.inner.set_len(len, ctx).await
|
||||
}
|
||||
|
||||
pub async fn fallocate_keep_size(
|
||||
pub async fn fallocate(
|
||||
&self,
|
||||
offset: i64,
|
||||
size: i64,
|
||||
ctx: &RequestContext,
|
||||
) -> Result<(), Error> {
|
||||
self.inner.fallocate_keep_size(offset, size, ctx).await
|
||||
self.inner.fallocate(offset, size, ctx).await
|
||||
}
|
||||
|
||||
pub async fn metadata(&self) -> Result<Metadata, Error> {
|
||||
@@ -647,16 +647,14 @@ impl VirtualFileInner {
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn fallocate_keep_size(
|
||||
pub async fn fallocate(
|
||||
&self,
|
||||
offset: i64,
|
||||
size: i64,
|
||||
_ctx: &RequestContext,
|
||||
) -> Result<(), Error> {
|
||||
with_file!(self, StorageIoOperation::Fallocate, |file_guard| {
|
||||
let (_file_guard, res) = io_engine::get()
|
||||
.fallocate_keep_size(file_guard, offset, size)
|
||||
.await;
|
||||
let (_file_guard, res) = io_engine::get().fallocate(file_guard, offset, size).await;
|
||||
res.maybe_fatal_err("fallocate") // TODO haven't thought about this
|
||||
})
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ impl IoEngine {
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) async fn fallocate_keep_size(
|
||||
pub(super) async fn fallocate(
|
||||
&self,
|
||||
file_guard: FileGuard,
|
||||
offset: i64,
|
||||
@@ -250,11 +250,17 @@ impl IoEngine {
|
||||
file_guard.with_std_file(|std_file| {
|
||||
fallocate(
|
||||
std_file.as_raw_fd(),
|
||||
FallocateFlags::FALLOC_FL_KEEP_SIZE,
|
||||
// NB: if you ever think of using FALLOC_FL_KEEP_SIZE, keep
|
||||
// in mind that I have found it to be punting to io_uring worker threads
|
||||
// on Debian Bookworm Linux 6.1.0-32-amd64 and 6.12.25 mainline.
|
||||
// => https://gist.github.com/problame/ed876bea40b915ba53267b8265e99352
|
||||
FallocateFlags::empty(),
|
||||
offset,
|
||||
len,
|
||||
)
|
||||
.expect("TODO")
|
||||
.expect("TODO");
|
||||
std_file.sync_all().unwrap();
|
||||
()
|
||||
});
|
||||
(file_guard, Ok(()))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user