speedup git shallow cloning: Enable gix/max-performance (#1186)

for targets:
 - x86_64-apple-darwin
 - aarch64-apple-darwin
 - x86_64-unknown-linux-gnu
 - x86_64-unknown-linux-musl

which will use `zlib-ng` to speedup decompression and use assembly
version for sha1 checksum calculation on supported CPU.

Also enable feature `zlib-ng` on windows and
 - aarch64-unknown-linux-gnu
 - aarch64-unknown-linux-musl

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2023-07-10 16:18:15 +10:00 committed by GitHub
parent 7dea40a99a
commit 9d4694219b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 58 additions and 2 deletions

31
Cargo.lock generated
View file

@ -632,6 +632,15 @@ version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa"
[[package]]
name = "cpufeatures"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03e69e28e9f7f77debdedbaafa2866e1de9ba56df55a8bd7cfc724c25a09987c"
dependencies = [
"libc",
]
[[package]] [[package]]
name = "crc32fast" name = "crc32fast"
version = "1.3.2" version = "1.3.2"
@ -1298,6 +1307,7 @@ dependencies = [
"once_cell", "once_cell",
"parking_lot", "parking_lot",
"prodash", "prodash",
"sha1",
"sha1_smol", "sha1_smol",
"thiserror", "thiserror",
"walkdir", "walkdir",
@ -3098,6 +3108,27 @@ dependencies = [
"unsafe-libyaml", "unsafe-libyaml",
] ]
[[package]]
name = "sha1"
version = "0.10.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3"
dependencies = [
"cfg-if",
"cpufeatures",
"digest",
"sha1-asm",
]
[[package]]
name = "sha1-asm"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "563d4f7100bc3fce234e5f37bbf63dc2752558964505ba6ac3f7204bdc59eaac"
dependencies = [
"cc",
]
[[package]] [[package]]
name = "sha1_smol" name = "sha1_smol"
version = "1.0.0" version = "1.0.0"

View file

@ -52,6 +52,7 @@ embed-resource = "2.1.1"
default = ["static", "rustls", "trust-dns", "fancy-no-backtrace", "zstd-thin", "git"] default = ["static", "rustls", "trust-dns", "fancy-no-backtrace", "zstd-thin", "git"]
git = ["binstalk/git"] git = ["binstalk/git"]
git-max-perf = ["binstalk/git-max-perf"]
mimalloc = ["dep:mimalloc"] mimalloc = ["dep:mimalloc"]

View file

@ -52,6 +52,7 @@ windows = { version = "0.48.0", features = ["Win32_Storage_FileSystem", "Win32_F
default = ["static", "rustls", "git"] default = ["static", "rustls", "git"]
git = ["dep:gix"] git = ["dep:gix"]
git-max-perf = ["gix?/max-performance"]
static = ["binstalk-downloader/static"] static = ["binstalk-downloader/static"]
pkg-config = ["binstalk-downloader/pkg-config"] pkg-config = ["binstalk-downloader/pkg-config"]

View file

@ -73,9 +73,32 @@ support-pkg-config := if target == target-host {
if target-os == "linux" { "true" } else { "" } if target-os == "linux" { "true" } else { "" }
} else { "" } } else { "" }
enable-git-max-perf-feature := if target == "x86_64-apple-darwin" {
"true"
} else if target == "aarch64-apple-darwin" {
"true"
} else if target == "x86_64-unknown-linux-gnu" {
"true"
} else if target == "x86_64-unknown-linux-musl" {
"true"
} else {
"false"
}
git-max-perf-feature := if enable-git-max-perf-feature == "true" {
",git-max-perf"
} else if target-os == "windows" {
",zlib-ng"
} else if target == "aarch64-unknown-linux-gnu" {
",zlib-ng"
} else if target == "aarch64-unknown-linux-musl" {
",zlib-ng"
} else {
""
}
cargo-features := trim_end_match(if override-features != "" { override-features cargo-features := trim_end_match(if override-features != "" { override-features
} else if (cargo-profile / ci-or-no) == "dev/ci" { "git,rustls,fancy-with-backtrace,zstd-thin,log_max_level_debug" + (if support-pkg-config != "" { ",pkg-config" } else { "" }) + extra-features } else if (cargo-profile / ci-or-no) == "dev/ci" { "git,rustls,fancy-with-backtrace,zstd-thin,log_max_level_debug" + git-max-perf-feature + (if support-pkg-config != "" { ",pkg-config" } else { "" }) + extra-features
} else if (cargo-profile / ci-or-no) == "release/ci" { "git,static,rustls,trust-dns,fancy-no-backtrace,zstd-thin,log_release_max_level_debug,cross-lang-fat-lto" + extra-features } else if (cargo-profile / ci-or-no) == "release/ci" { "git,static,rustls,trust-dns,fancy-no-backtrace,zstd-thin,log_release_max_level_debug,cross-lang-fat-lto" + git-max-perf-feature + extra-features
} else { extra-features } else { extra-features
}, ",") }, ",")