diff options
| author | Matheus Alves de Almeida <matheus.aalmeida@inf.ufrgs.br> | 2026-10-23 22:30:20 -0300 |
|---|---|---|
| committer | Andrew Morton <akpm@linux-foundation.org> | 2026-11-02 19:18:55 -0800 |
| commit | 4bdfe8dd2342f9c2bdc3b788699164ebe21d9126 (patch) | |
| tree | 7efcd7fb2c1cab07f9d58f2aa516c7bc92e8a706 /tools/perf/scripts/python | |
| parent | cd7c3563a98fe8c984463d83772e518cb7e68356 (diff) | |
fat: preallocate space before expanding in fat_cont_expand()
The fat_cont_expand() implementation leaves allocation of new clusters
to generic_cont_expand_simple(). This path does many small cluster
allocations, harming performance.
Preallocate cluster space in fat_cont_expand(). Move preallocation to
a new fat_preallocate() helper used by both fat_cont_expand() and
fat_fallocate(FALLOC_FL_KEEP_SIZE). Use a FAT-specific
fat_cont_expand_simple() instead of generic_cont_expand_simple() to
avoid rechecking the new size after clusters have been allocated.
Benchmarking was done under QEMU/KVM with a virtio-blk device using
cache=none. Each result is the arithmetic mean of the listed samples.
start = now_ns();
for (unsigned i = 0; i < count; i++) {
if (truncate_mode)
ftruncate(fds[i], bytes);
else
fallocate(fds[i], 0, 0, bytes);
}
elapsed = now_ns() - start;
16 files, 512-byte clusters:
length mode sync? before after improvement samples
256MiB ftruncate no 9.576s 5.345s 1.79x 10
256MiB fallocate no 9.634s 5.640s 1.71x 10
1MiB ftruncate yes 58.66s 0.362s 162.15x 5
1MiB fallocate yes 61.36s 0.390s 157.15x 5
128 files, 512-byte clusters:
length mode sync? before after improvement samples
512KiB ftruncate no 0.433s 0.352s 1.23x 10
512KiB fallocate no 0.446s 0.393s 1.13x 10
64KiB ftruncate yes 31.32s 0.429s 73.00x 10
64KiB fallocate yes 29.59s 0.410s 72.42x 10
16 files, 4096-byte clusters:
length mode sync? before after improvement samples
256MiB ftruncate no 5.181s 4.417s 1.17x 10
256MiB fallocate no 5.166s 4.442s 1.16x 10
1MiB ftruncate yes 9.294s 0.111s 84.06x 10
1MiB fallocate yes 8.710s 0.110s 79.36x 10
The biggest improvement is on filesystems with a small cluster size and
on synchronous mounts.
Link: https://lore.kernel.org/20261024013021.251898-1-matheus.aalmeida@inf.ufrgs.br
Signed-off-by: Matheus Alves de Almeida <matheus.aalmeida@inf.ufrgs.br>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Diffstat (limited to 'tools/perf/scripts/python')
0 files changed, 0 insertions, 0 deletions
