From 99013ae9567fef32ddc54906f43e0ac2d78b9111 Mon Sep 17 00:00:00 2001 From: Ed Morley <501702+edmorley@users.noreply.github.com> Date: Fri, 1 Mar 2024 10:56:10 +0000 Subject: [PATCH] Switch to the `zlib` flate2 backend The default `miniz_oxide` flate2 backend has poor performance in debug/under QEMU: https://github.com/rust-lang/flate2-rs/issues/297 Ideally we'd use the fastest `zlib-ng` backend, however it fails to cross-compile: https://github.com/rust-lang/libz-sys/issues/93 As such we have to use the next best alternate backend, which is `zlib`. This makes the `flate2` usage in this repo consistent with `libherokubuildpack`, Python CNB, PHP CNB etc. --- Cargo.lock | 24 ++++++++++++++++++++++++ buildpacks/ruby/Cargo.toml | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index fb891522..2034e9fa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -374,6 +374,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" dependencies = [ "crc32fast", + "libz-sys", "miniz_oxide", ] @@ -674,6 +675,17 @@ dependencies = [ "sha2", ] +[[package]] +name = "libz-sys" +version = "1.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "037731f5d3aaa87a5675e895b63ddff1a87624bc29f77004ea829809654e48f6" +dependencies = [ + "cc", + "pkg-config", + "vcpkg", +] + [[package]] name = "linux-raw-sys" version = "0.4.13" @@ -741,6 +753,12 @@ dependencies = [ "indexmap", ] +[[package]] +name = "pkg-config" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -1199,6 +1217,12 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86bd8d4e895da8537e5315b8254664e6b769c4ff3db18321b297a1e7004392e3" +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "version_check" version = "0.9.4" diff --git a/buildpacks/ruby/Cargo.toml b/buildpacks/ruby/Cargo.toml index 0e444ec8..62cdbc94 100644 --- a/buildpacks/ruby/Cargo.toml +++ b/buildpacks/ruby/Cargo.toml @@ -9,7 +9,7 @@ workspace = true [dependencies] clap = { version = "4", default-features = false, features = ["derive", "error-context", "help", "std", "usage"] } commons = { path = "../../commons" } -flate2 = "1" +flate2 = { version = "1", default-features = false, features = ["zlib"] } fs-err = "2" fun_run = { version = "0.1", features = ["which_problem"] } glob = "0.3"