From 40c0d808313724e1aa7b28c1fb5375f40f7ba920 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 18 Oct 2024 18:15:29 +0200 Subject: [PATCH] io/CopyRegularFile: skip fallocate() for small files Not worth the system call overhead. --- src/io/CopyRegularFile.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/io/CopyRegularFile.cxx b/src/io/CopyRegularFile.cxx index 0c850519d..84f3d9002 100644 --- a/src/io/CopyRegularFile.cxx +++ b/src/io/CopyRegularFile.cxx @@ -58,7 +58,8 @@ CopyRegularFile(FileDescriptor src, FileDescriptor dst, off_t size) posix_fadvise(src.Get(), 0, size, POSIX_FADV_SEQUENTIAL); - fallocate(dst.Get(), FALLOC_FL_KEEP_SIZE, 0, size); + if (size > 32768) + fallocate(dst.Get(), FALLOC_FL_KEEP_SIZE, 0, size); while (size > 0) { std::array buffer;