From e7450c33fad7bf78816eff7b2506e7926d171d16 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 41ddb4e7ec..faa7d681bd 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 2.0.4", "walkdir", @@ -2010,6 +2021,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" @@ -2870,6 +2891,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 fabddd4cc8..afaf35d70c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -61,7 +61,7 @@ gix = { version = "0.68.0", default-features = false, features = [ "attributes", "blob-diff", "index", - "max-performance-safe", + "max-performance", ] } glob = "0.3.1" hashbrown = { version = "0.15.2", default-features = false, features = ["inline-more"] } diff --git a/flake.nix b/flake.nix index 6021840ccc..567aed25d8 100644 --- a/flake.nix +++ b/flake.nix @@ -98,8 +98,11 @@ makeWrapper pkg-config + # for libz-ng-sys (zlib-ng) + cmake + # for signing tests - gnupg + gnupg openssh ] ++ linuxNativeDeps; buildInputs = with pkgs; [