Code Monkey home page Code Monkey logo

fcp's Introduction

fcp

CI status fcp crate Packaging status

fcp is a significantly faster alternative to the classic Unix cp(1) command.

fcp aims to handle the most common use-cases of cp with much higher performance.

fcp does not aim to completely replace cp with its myriad options.

Note: fcp is optimized for systems with an SSD. On systems with a HDD, fcp may exhibit poor performance.

Installation

Please note that fcp supports only Unix-like operating systems (e.g. Linux, macOS, etc.).

Pre-built binaries

Pre-built binaries for some systems can be found under this repository's releases.

Via cargo

fcp requires Rust version 1.53.0 or newer. fcp can be installed using cargo by running the following:

cargo install fcp

Arch Linux

fcp can be installed on Arch Linux via the fcp-bin AUR.

NixOS

As of NixOS 21.11 fcp is included in the stable channel. For earlier versions, fcp is available through nixpkgs-unstable. Assuming you've already added the nixpkgs-unstable channel, fcp can be installed by running the following:

nix-env -iA unstable.fcp

macOS

fcp can be installed on macOS via Homebrew by running the following:

brew install fcp

Usage

Usage information can be found by running fcp --help, and has been reproduced below:

fcp 0.2.1

USAGE:
    fcp [OPTIONS] SOURCE DESTINATION_FILE
    Copy SOURCE to DESTINATION_FILE, overwriting DESTINATION_FILE if it exists

    fcp [OPTIONS] SOURCE ... DESTINATION_DIRECTORY
    Copy each SOURCE into DESTINATION_DIRECTORY

OPTIONS:
    -h, --help
            Output this usage information and exit.

    -V, --version
            Output version information and exit.

Benchmarks

fcp doesn't just claim to be faster than cp, it is faster than cp. As different operating systems display different performance characteristics, the same benchmarks were run on both macOS and Linux.

macOS

The following benchmarks were run on a 2018 MacBook Pro1 (2.9 GHz 6-Core Intel Core i9, 16 GiB RAM, SSD) with APFS as the filesystem.

Large Files

The following shows the result of a benchmark which copies a directory containing 13 different 512 MB files using cp and fcp, with fcp being approximately 822x faster on average (note the units of the axes for each plot)2:

fcp is approximately 822x faster than cp, with fcp's average time to copy being approximately 4.5 milliseconds, while cp's average time to copy is approximately 3.7 seconds

Linux Kernel Source

The following shows the result of a benchmark which copies the source tree of the Linux kernel using cp and fcp, with fcp being approximately 6x faster on average:

fcp is approximately 6x faster than cp, with fcp's average time to copy being approximately 5.1 seconds, while cp's average time to copy is approximately 30 seconds

Linux

The following benchmarks were run on a bare-metal AWS EC2 instance (a1.metal, 16 CPUs, 32 GiB RAM, SSD) with XFS as the filesystem.

Linux Kernel Source

The following shows the result of a benchmark which copies the source tree of the Linux kernel using cp and fcp, with fcp being approximately 10x faster on average:

fcp is nearly 10x faster than cp, with fcp's average time to copy being approximately 675 milliseconds, while cp's average time to copy is approximately 6.02 seconds

Large Files

The following shows the result of a benchmark which copies a directory containing 13 different 512 MB files using cp and fcp, with fcp being approximately 1.4x faster on average:

fcp is approximately 1.4x faster than cp, with fcp's average time to copy being approximately 8 seconds, while cp`'s average time to copy is approximately 11.3 seconds

Methodology

fcp's high-performance can be attributed to several factors, but is primarily the result of leveraging parallelism, distributing the work of walking directories and copying their contents across all of your machine's cores. This leads to a significant performance increase on systems with an SSD, as more I/O requests are issued over the same period of time (as compared to a single-threaded approach), resulting in a higher-average queue depth, thus allowing higher utilization of the SSD (as a function of its maximum IOPS) and correspondingly higher throughput.

Additionally, on macOS (and perhaps in the future on other operating systems) fcp utilizes the system's underlying copy-on-write capability, dramatically reducing the time needed to copy large files.

These two factors โ€“ in addition to an overall performance-conscious approach to this problem โ€“ serve to explain fcp's significantly improved performance relative to cp.


[1] While in general you should avoid benchmarking on laptops, fcp is a developer tool and many developers work primarily on laptops. Also unlike with Linux where you can rent by the second, the minimum tenancy for AWS EC2 macOS instances is 24 hours, and these benchmarks took less than an hour.

[2] The massive difference in performance in this case is due to fcp using fclonefileat and fcopyfile under the hood.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.