The Linux "copy problem"
The Linux "copy problem"
Posted May 30, 2019 13:38 UTC (Thu) by desbma (guest, #118820)In reply to: The Linux "copy problem" by ecree
Parent article: The Linux "copy problem"
According to `man splice`:
> splice() moves data between two file descriptors [...] where one of the file descriptors must refer to a pipe
> splice() moves data between two file descriptors [...] where one of the file descriptors must refer to a pipe
sendfile does not have this restriction (it can also work if the destination fd is a socket), so it is the ideal candidate for copying files.
Apparently, someone proposed to update coreutil's cp to use sendfile in 2012, but it was rejected: https://lists.gnu.org/archive/html/coreutils/2012-10/msg0...
A while ago I did some benchmarks in Python to compare "read/write chunk" vs "sendfile" based copy, and it let to a 30-50% speedup : https://github.com/desbma/pyfastcopy#performance
