cargo: use gix/zlib-rs feature

This uses `zlib-rs`, a native Rust library that is comparable in
performance to `zlib-ng`. Since there’s no complicated C build
and gitoxide only has one hashing backend now, this lets us drop our
`packaging` feature without adding any awkward build requirements.

`zlib-rs` is generally faster at decompression than
`zlib-ng`, and faster at compression on levels 6 and 9; see
<https://trifectatech.org/blog/zlib-rs-is-faster-than-c/>
for details.

I couldn’t get reliable‐looking benchmark results out of my
temperamental laptop; `hyperfine` seemed to think that some random
`jj` workloads I tested might be slightly slower than with `zlib-ng`,
but it wasn’t unambiguously distinguishable from noise, so I’d
like to see measurements from others.

It’s certainly a lot faster than the previous default, and I
think it’s likely that `zlib-rs` will continue to get faster
and that it’s more than worth avoiding the headaches of a native
library with a CMake build dependency. (Though on the other hand,
if distributions move in the direction of shipping `zlib-ng` by
default, maybe there will be more motivation to make `libz-ng-sys`
support system libraries.)
This commit is contained in:
Emily 2025-03-27 17:48:17 +00:00
parent 1716b7f8d3
commit e5478bbf7b
9 changed files with 21 additions and 31 deletions

View File

@ -56,7 +56,7 @@ jobs:
target: ${{ matrix.target }}
- name: Build release binary
shell: bash
run: cargo build --target ${{ matrix.target }} --verbose --release --features packaging,vendored-openssl
run: cargo build --target ${{ matrix.target }} --verbose --release --features vendored-openssl
- name: Set up artifact directory
shell: bash

View File

@ -52,7 +52,7 @@ jobs:
target: ${{ matrix.target }}
- name: Build release binary
shell: bash
run: cargo build --target ${{ matrix.target }} --verbose --release --features packaging,vendored-openssl
run: cargo build --target ${{ matrix.target }} --verbose --release --features vendored-openssl
- name: Build archive
shell: bash
run: |

View File

@ -31,6 +31,13 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
### Fixed bugs
### Packaging changes
* Jujutsu now uses
[`zlib-rs`](https://github.com/trifectatechfoundation/zlib-rs), a
fast compression library written in Rust. Packagers should remove any
dependency on CMake and drop the `packaging` Cargo feature.
## [0.28.2] - 2025-04-07
### Fixed bugs

26
Cargo.lock generated
View File

@ -465,15 +465,6 @@ version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cbd0f76e066e64fdc5631e3bb46381254deab9ef1158292f27c8c57e3bf3fe59"
[[package]]
name = "cmake"
version = "0.1.54"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7caa3f9de89ddbe2c607f4101924c5abec803763ae9534e4f4d7d8f84aa81f0"
dependencies = [
"cc",
]
[[package]]
name = "colorchoice"
version = "1.0.3"
@ -898,7 +889,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ced92e76e966ca2fd84c8f7aa01a4aea65b0eb6648d72f7c8f3e2764a67fece"
dependencies = [
"crc32fast",
"libz-ng-sys",
"libz-rs-sys",
"miniz_oxide",
]
@ -2495,13 +2486,12 @@ dependencies = [
]
[[package]]
name = "libz-ng-sys"
version = "1.1.22"
name = "libz-rs-sys"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7118c2c2a3c7b6edc279a8b19507672b9c4d716f95e671172dfa4e23f9fd824"
checksum = "6489ca9bd760fe9642d7644e827b0c9add07df89857b0416ee15c1cc1a3b8c5a"
dependencies = [
"cmake",
"libc",
"zlib-rs",
]
[[package]]
@ -4941,3 +4931,9 @@ dependencies = [
"quote",
"syn 2.0.100",
]
[[package]]
name = "zlib-rs"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "868b928d7949e09af2f6086dfc1e01936064cc7a819253bce650d4e2a2d63ba8"

View File

@ -59,6 +59,7 @@ gix = { version = "0.71.0", default-features = false, features = [
"blob-diff",
"index",
"max-performance-safe",
"zlib-rs",
] }
glob = "0.3.2"
hashbrown = { version = "0.15.2", default-features = false, features = ["inline-more"] }

View File

@ -113,8 +113,6 @@ default = ["watchman", "git", "git2"]
bench = ["dep:criterion"]
git = ["jj-lib/git", "dep:gix"]
git2 = ["git", "jj-lib/git2", "dep:git2"]
gix-max-performance = ["jj-lib/gix-max-performance"]
packaging = ["gix-max-performance"]
test-fakes = ["jj-lib/testing"]
vendored-openssl = ["git2/vendored-openssl", "jj-lib/vendored-openssl"]
watchman = ["jj-lib/watchman"]

View File

@ -93,7 +93,6 @@ allow = [
"Apache-2.0 WITH LLVM-exception",
"Apache-2.0",
"BSD-3-Clause",
"ISC",
"MIT",
"MPL-2.0",
"Unicode-3.0",

View File

@ -64,10 +64,6 @@
[
gzip
pkg-config
# for libz-ng-sys (zlib-ng)
# TODO: switch to the packaged zlib-ng and drop this dependency
cmake
]
++ lib.optionals stdenv.isLinux [
mold-wrapped
@ -109,7 +105,6 @@
pname = "jujutsu";
version = "unstable-${self.shortRev or "dirty"}";
buildFeatures = ["packaging"];
cargoBuildFlags = ["--bin" "jj"]; # don't build and install the fake editors
useNextest = true;
cargoTestFlags = ["--profile" "ci"];

View File

@ -97,12 +97,6 @@ tokio = { workspace = true, features = ["full"] }
default = ["git", "git2"]
git = ["dep:gix"]
git2 = ["git", "dep:git2"]
gix-max-performance = [
# Requires `cmake` as a build dependency.
# Note that this feature is different from `gix/max-performance-safe`.
# See: https://docs.rs/gix/latest/gix/#performance
"gix/max-performance",
]
vendored-openssl = ["git2/vendored-openssl"]
watchman = ["dep:tokio", "dep:watchman_client"]
testing = ["git"]