From 5842530e057d614a81a434b6f75f636abdfd0056 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Wed, 20 Nov 2024 22:07:31 +0900 Subject: [PATCH] cargo: enable zlib-ng and fast sha1 in gix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I noticed miniz_oxide appears in perf samples. While miniz_oxide is safer, I think zlib-ng is pretty reliable. https://docs.rs/gix/latest/gix/#performance libz-ng-sys is downgraded to 1.1.16 due to the Windows linking issue. The benchmark result is obtained with libz-ng-sys 1.1.20. https://github.com/rust-lang/libz-sys/issues/225 ``` % hyperfine --sort command --warmup 3 --runs 10 -L bin jj-0,jj-1 \ 'target/release-with-debug/{bin} --ignore-working-copy log README.md' Benchmark 1: target/release-with-debug/jj-0 .. Time (mean ± σ): 256.6 ms ± 4.3 ms [User: 214.1 ms, System: 38.6 ms] Range (min … max): 245.4 ms … 261.2 ms 10 runs Benchmark 2: target/release-with-debug/jj-1 .. Time (mean ± σ): 223.0 ms ± 4.2 ms [User: 174.7 ms, System: 44.4 ms] Range (min … max): 212.4 ms … 225.8 ms 10 runs ``` --- Cargo.lock | 42 ++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 2 +- flake.nix | 5 ++++- 3 files changed, 47 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dccad0fe4d..abe72015a0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -429,6 +429,15 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cbd0f76e066e64fdc5631e3bb46381254deab9ef1158292f27c8c57e3bf3fe59" +[[package]] +name = "cmake" +version = "0.1.51" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb1e43aa7fd152b1f968787f7dbcdeb306d1867ff373c69955211876c053f91a" +dependencies = [ + "cc", +] + [[package]] name = "colorchoice" version = "1.0.2" @@ -756,6 +765,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "324a1be68054ef05ad64b861cc9eaf1d623d2d8cb25b4bf2cb9cdd902b4bf253" dependencies = [ "crc32fast", + "libz-ng-sys", "miniz_oxide 0.8.0", ] @@ -1139,6 +1149,7 @@ dependencies = [ "once_cell", "parking_lot", "prodash", + "sha1", "sha1_smol", "thiserror", "walkdir", @@ -2008,6 +2019,16 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "libz-ng-sys" +version = "1.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4436751a01da56f1277f323c80d584ffad94a3d14aecd959dd0dff75aa73a438" +dependencies = [ + "cmake", + "libc", +] + [[package]] name = "libz-sys" version = "1.1.20" @@ -2868,6 +2889,27 @@ dependencies = [ "serde", ] +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", + "sha1-asm", +] + +[[package]] +name = "sha1-asm" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "286acebaf8b67c1130aedffad26f594eff0c1292389158135327d2e23aed582b" +dependencies = [ + "cc", +] + [[package]] name = "sha1_smol" version = "1.0.1" diff --git a/Cargo.toml b/Cargo.toml index 6d13e768d2..cc8afa3a2e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -61,7 +61,7 @@ gix = { version = "0.67.0", default-features = false, features = [ "attributes", "blob-diff", "index", - "max-performance-safe", + "max-performance", ] } glob = "0.3.1" hashbrown = { version = "0.15.1", default-features = false, features = ["inline-more"] } diff --git a/flake.nix b/flake.nix index d0d635077b..d1d7094d56 100644 --- a/flake.nix +++ b/flake.nix @@ -91,8 +91,11 @@ makeWrapper pkg-config + # for libz-ng-sys (zlib-ng) + cmake + # for signing tests - gnupg + gnupg openssh ] ++ linuxNativeDeps; buildInputs = with pkgs; [