xcp is a (partial) clone of the Unix cp command. It is not intended as a
full replacement, but as a companion utility with some more user-friendly
feedback and some optimisations that make sense under certain tasks (see
below).
Warning: xcp is currently beta-level software and almost certainly contains
bugs and unexpected or inconsistent behaviour. It probably shouldn't be used for
anything critical yet.
NOTE: xcp requires Rust 1.36 or higher.
xcp can be installed directly from crates.io with:
cargo install xcp
xcp is available on the Arch Linux User Repository. If you use an AUR helper, you can execute a command such as this:
yay -S xcp
--no-progress.copy_file_range call to copy files. This is the most
efficient method of file-copying under Linux; in particular it is
filesystem-aware, and can massively speed-up copies on network mounts by
performing the copy operations server-side. However, unlike copy_file_range
sparse files are detected and handled appropriately..gitignore files to limit the copied directories.cp's
--sparse=always flag.lseek.copy_file_range() requires a kernel version of 4.5 and onwards; if
it is missing xcp will fall-back to user-space copy.cp's features and flags, although these could be
added.Benchmarks are mostly meaningless, but to check we're not introducing too much
overhead for local copies, the following are results from a laptop with an NVMe
disk and in single-user mode. The target copy directory is a git checkout of the
Firefox codebase, having been recently gc'd (i.e. a single 4.1GB pack
file). fstrim -va is run before each test run to minimise SSD allocation
performance interference.
cp: ~6.2sxcp: ~4.2scp: ~1.85sxcp: ~1.7scp: ~48sxcp: ~56scp: ~6.9sxcp: ~7.4sxcp uses copy_file_range, which is filesystem aware. On NFSv4 this will result
in the copy occurring server-side rather than transferring across the network. For
large files this can be a significant win:
cp: 378sxcp: ~37s