Skip to content

Commit

Permalink
io/CopyRegularFile: skip fallocate() for small files
Browse files Browse the repository at this point in the history
Not worth the system call overhead.
  • Loading branch information
MaxKellermann committed Oct 18, 2024
1 parent 3b5002f commit 40c0d80
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/io/CopyRegularFile.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::byte, 65536> buffer;
Expand Down

0 comments on commit 40c0d80

Please sign in to comment.