|0.9.4||Feb 26, 2023|
|0.9.3||Oct 4, 2022|
|0.9.1||May 12, 2022|
|0.9.0||Oct 10, 2020|
|0.1.1-alpha.3||Nov 21, 2018|
#20 in Command line utilities
308 downloads per month
xcp: An extended cp
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
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.
Additionally, there are some known issues with copying files from virtual
/sys), especially when using the block-parallel
('parblock') driver. See this LWN article
for an overview of some of the complexities of dealing with kernel-generated
files. There are some preliminary tests for this failing functionality on the
xcp requires Rust 1.64 (2021 edition) or higher.
xcp can be installed directly from
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
xcp is available on NetBSD from the official repositories. To install it, simply run:
pkgin install xcp
Features and Anti-Features
- Displays a progress-bar, both for directory and single file copies. This can
be disabled with
- On Linux it uses
copy_file_rangecall 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_rangesparse files are detected and handled appropriately.
- Optimised for 'modern' systems (i.e. multiple cores, copious RAM, and solid-state disks, especially ones connected into the main system bus, e.g. NVMe).
- Optional aggressive parallelism for systems with parallel IO. Quick experiments on a modern laptop suggest there may be benefits to parallel copies on NVMe disks. This is obviously highly system-dependent.
- Switchable 'drivers' to facilitate experimenting with alternative strategies
for copy optimisation. Currently 2 drivers are available:
- 'parfile': the previous hard-coded xcp copy method, which parallelises tree-walking and per-file copying. This is the default.
- 'parblock': An experimental driver that parallelises copying at the block level. This has the potential for performance improvements in some architectures, but increases complexity. Currently MacOS is not supported. Testing is welcome.
- Non-Linux Unix-like OSs (OS X, *BSD) are supported via fall-back operation (although sparse-files are not yet supported in this case).
- Optionally understands
.gitignorefiles to limit the copied directories.
- Optional native file-globbing.
(Possible) future features
- Conversion of files to sparse where appropriate, as with
- Aggressive sparseness detection with
- On Linux
copy_file_range()requires a kernel version of 4.5 and onwards; if it is missing
xcpwill fall-back to user-space copy.
- On non-Linux OSs sparse-files are not supported (although could be added if supported by the OS).
- Assumes a 'modern' system with lots of RAM and fast, solid-state disks. In particular it is likely to thrash on spinning disks as it attempts to gather metadata and perform copies at the same time.
- Currently missing a lot of
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
fstrim -va is run before each test run to minimise SSD allocation
- Single 4.1GB file copy, with the kernel cache dropped each run:
- Single 4.1GB file copy, warmed cache (3 runs each):
- Directory copy, kernel cache dropped each run:
- Directory copy, warmed cache (3 runs each):
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:
- Single 4.1GB file on NFSv4 mount