split: advise the kernel of sequential access pattern
commit059e53e5b49d8a2314045c796d813f51dd862069
authorPádraig Brady <P@draigBrady.com>
Mon, 8 May 2023 20:22:48 +0000 (8 21:22 +0100)
committerPádraig Brady <P@draigBrady.com>
Mon, 8 May 2023 20:34:58 +0000 (8 21:34 +0100)
tree93ddb70b92b2d0bdacc6d58cf4df79ec736dbac1
parentba128e628cfa0dd111cf235d965200d1cdf77f52
split: advise the kernel of sequential access pattern

As split is often dealing with large files,
ensure we indicate to the kernel our sequential access pattern.
This was seen to operate 5% faster when reading from SSD,
as tested with:

dd bs=1M count=2K if=/dev/urandom of=big.in

for split in split.orig split; do
  # Ensure big file is not cached
  dd of=big.in oflag=nocache conv=notrunc,fdatasync count=0 status=none
  # Test read efficiency
  CWD=$PWD; (cd /dev/shm && time $CWD/src/$split -n2 $CWD/big.in)
done

real    0m9.039s
user    0m0.055s
sys     0m3.510s

real    0m8.568s
user    0m0.056s
sys     0m3.752s

* src/split.c (main): Use fdadvise to help the kernel
choose a more appropriate readahead buffer.
* NEWS: Mention the improvement.
NEWS
src/split.c