Skip to content

Instantly share code, notes, and snippets.

@schlarpc
Created April 10, 2023 17:34
Show Gist options
  • Save schlarpc/20bca64eb7cd76733c459941df5759f8 to your computer and use it in GitHub Desktop.
Save schlarpc/20bca64eb7cd76733c459941df5759f8 to your computer and use it in GitHub Desktop.
hash-speedtest
{ pkgs ? import <nixpkgs> {} }:
let
libkcapi = pkgs.stdenv.mkDerivation {
pname = "libkcapi";
version = "a05976bef9c4d4dbe48323e8cdbe2c886f35b9ff";
src = pkgs.fetchFromGitHub {
repo = "libkcapi";
owner = "smuellerDD";
rev = "a05976bef9c4d4dbe48323e8cdbe2c886f35b9ff";
sha256 = "sha256-TjTER1AiPyILOx+oyZmt0WSPxEMo0oP+dAYZK6O3BM4=";
};
nativeBuildInputs = [ pkgs.autoreconfHook ];
configureFlags = [ "--enable-kcapi-hasher" ];
};
btrfs-progs = pkgs.btrfs-progs.overrideAttrs (old: {
buildInputs = old.buildInputs ++ [ libkcapi ];
configureFlags = old.configureFlags ++ [ "--with-crypto=libkcapi" ];
postBuild = (old.postBuild or "") + ''
make hash-speedtest
'';
postInstall = (old.postInstall or "") + ''
cp hash-speedtest $out/bin
'';
});
in btrfs-progs
Block size: 4096
Iterations: 100000
Implementation: libkcapi
Units: CPU cycles
NULL-NOP: cycles: 23156060, cycles/i 231
NULL-MEMCPY: cycles: 48894774, cycles/i 488, 20672.836 MiB/s
CRC32C: cycles: 152103176, cycles/i 1521, 6645.493 MiB/s
XXHASH: cycles: 110446886, cycles/i 1104, 9151.921 MiB/s
SHA256: cycles: 5455381428, cycles/i 54553, 185.286 MiB/s
BLAKE2: cycles: 2412114586, cycles/i 24121, 419.054 MiB/s
Block size: 4096
Iterations: 100000
Implementation: builtin
Units: CPU cycles
NULL-NOP: cycles: 25276646, cycles/i 252
NULL-MEMCPY: cycles: 49015106, cycles/i 490, 20622.684 MiB/s
CRC32C: cycles: 152226114, cycles/i 1522, 6640.306 MiB/s
XXHASH: cycles: 110294130, cycles/i 1102, 9164.827 MiB/s
SHA256: cycles: 8371201420, cycles/i 83712, 120.751 MiB/s
BLAKE2: cycles: 1565432874, cycles/i 15654, 645.718 MiB/s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment