Skip to content

Commit

Permalink
Clean up "performance allocators" and "performance flate2" backends (#…
Browse files Browse the repository at this point in the history
…7686)

Co-authored-by: Amos Wenger <[email protected]>
  • Loading branch information
konstin and fasterthanlime authored Sep 25, 2024
1 parent 12ab7d1 commit f5601e2
Show file tree
Hide file tree
Showing 15 changed files with 189 additions and 74 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/build-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,7 @@ jobs:
*.tar.gz
*.sha256
# Like `linux-arm`, but use `--no-default-features --features flate2/rust_backend` when
# building uv.
# Like `linux-arm`, but use `--no-default-features` when building uv.
linux-s390x:
if: ${{ !contains(github.event.pull_request.labels.*.name, 'no-build') }}
runs-on: ubuntu-latest
Expand All @@ -378,7 +377,7 @@ jobs:
target: ${{ matrix.platform.target }}
manylinux: auto
docker-options: ${{ matrix.platform.maturin_docker_options }}
args: --release --locked --out dist --no-default-features --features flate2/rust_backend --features self-update
args: --release --locked --out dist --no-default-features --features self-update
- uses: uraimo/run-on-arch-action@v2
if: matrix.platform.arch != 'ppc64'
name: Test wheel
Expand Down Expand Up @@ -421,8 +420,8 @@ jobs:
*.tar.gz
*.sha256
# Like `linux-arm`, but use `--no-default-features --features flate2/rust_backend` when
# building uv, and install the `gcc-powerpc64-linux-gnu` package.
# Like `linux-arm`, but use `--no-default-features` when building uv,
# and install the `gcc-powerpc64-linux-gnu` package.
linux-powerpc:
if: ${{ !contains(github.event.pull_request.labels.*.name, 'no-build') }}
runs-on: ubuntu-latest
Expand Down Expand Up @@ -453,7 +452,7 @@ jobs:
target: ${{ matrix.platform.target }}
manylinux: auto
docker-options: ${{ matrix.platform.maturin_docker_options }}
args: --release --locked --out dist --no-default-features --features flate2/rust_backend --features self-update
args: --release --locked --out dist --no-default-features --features self-update
before-script-linux: |
if command -v yum &> /dev/null; then
yum update -y
Expand Down
33 changes: 18 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ exclude = [
"scripts",
# Needs nightly
"crates/uv-trampoline",
# Only used to pull in features, allocators, etc. — we specifically don't want them
# to be part of a workspace-wide cargo check, cargo clippy, etc.
"crates/uv-performance-memory-allocator",
"crates/uv-performance-flate2-backend",
]
resolver = "2"

Expand Down
13 changes: 6 additions & 7 deletions crates/uv-dev/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,19 @@ tracing = { workspace = true }
tracing-durations-export = { workspace = true, features = ["plot"] }
tracing-subscriber = { workspace = true }
walkdir = { workspace = true }

[target.'cfg(target_os = "windows")'.dependencies]
mimalloc = { version = "0.1.43" }

[target.'cfg(all(not(target_os = "windows"), not(target_os = "openbsd"), any(target_arch = "x86_64", target_arch = "aarch64", target_arch = "powerpc64")))'.dependencies]
tikv-jemallocator = { version = "0.6.0" }
uv-performance-memory-allocator = { path = "../uv-performance-memory-allocator", optional = true }

[[bin]]
name = "uv-dev"
# We don't want to build the dev CLI by default, so we skip it by requiring an off-by-default feature
required-features = ["dev"]

[features]
default = []
default = ["performance"]
# Actually build the dev CLI.
dev = []
performance = ["dep:uv-performance-memory-allocator"]
render = ["poloto", "resvg", "tagu"]

[package.metadata.cargo-shear]
ignored = ["flate2", "uv-performance-memory-allocator", "uv-performance-flate2-backend"]
16 changes: 0 additions & 16 deletions crates/uv-dev/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,6 @@ use crate::generate_options_reference::Args as GenerateOptionsReferenceArgs;
use crate::render_benchmarks::RenderBenchmarksArgs;
use crate::wheel_metadata::WheelMetadataArgs;

#[cfg(target_os = "windows")]
#[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;

#[cfg(all(
not(target_os = "windows"),
not(target_os = "openbsd"),
any(
target_arch = "x86_64",
target_arch = "aarch64",
target_arch = "powerpc64"
)
))]
#[global_allocator]
static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;

mod clear_compile;
mod compile;
mod generate_all;
Expand Down
4 changes: 4 additions & 0 deletions crates/uv-distribution/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,7 @@ zip = { workspace = true }
[dev-dependencies]
indoc = { version = "2.0.5" }
insta = { version = "1.40.0", features = ["filters", "json", "redactions"] }

[features]
default = []
performance = ["uv-extract/performance"]
6 changes: 5 additions & 1 deletion crates/uv-extract/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ thiserror = { workspace = true }
tokio = { workspace = true }
tokio-util = { workspace = true, features = ["compat"] }
tracing = { workspace = true }
xz2 = { workspace = true, features = ["static"] }
xz2 = { workspace = true }
zip = { workspace = true }

[features]
default = []
performance = ["xz2/static"]

[package.metadata.cargo-shear]
ignored = ["xz2"]
10 changes: 10 additions & 0 deletions crates/uv-performance-flate2-backend/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "uv-performance-flate2-backend"
version = "0.1.0"
publish = false

[target.'cfg(not(any(target_arch = "s390x", target_arch = "powerpc64")))'.dependencies]
flate2 = { version = "1.0.28", default-features = false, features = ["zlib-ng"] }

[target.'cfg(any(target_arch = "s390x", target_arch = "powerpc64"))'.dependencies]
flate2 = { version = "1.0.28", default-features = false, features = ["rust_backend"] }
5 changes: 5 additions & 0 deletions crates/uv-performance-flate2-backend/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//! The sole purpose of this crate is to enable one of
//! `flate2/zlib-ng` (on most platforms) or `flate2/rust_backend`
//! (on s390x, powerpc64, etc. — anywhere libz-ng doesn't build)
//!
//! See `Cargo.toml`
71 changes: 71 additions & 0 deletions crates/uv-performance-memory-allocator/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions crates/uv-performance-memory-allocator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "uv-performance-memory-allocator"
version = "0.1.0"
publish = false

[dependencies]

[target.'cfg(all(target_os = "windows"))'.dependencies]
mimalloc = { version = "0.1.43" }

[target.'cfg(all(not(target_os = "windows"), not(target_os = "openbsd"), any(target_arch = "x86_64", target_arch = "aarch64", target_arch = "powerpc64")))'.dependencies]
tikv-jemallocator = { version = "0.6.0" }
18 changes: 18 additions & 0 deletions crates/uv-performance-memory-allocator/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//! The only purpose of this crate is to pull in `mimalloc` on windows and
//! `tikv-jemallocator` on most other platforms.
#[cfg(target_os = "windows")]
#[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;

#[cfg(all(
not(target_os = "windows"),
not(target_os = "openbsd"),
any(
target_arch = "x86_64",
target_arch = "aarch64",
target_arch = "powerpc64"
)
))]
#[global_allocator]
static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
Loading

0 comments on commit f5601e2

Please sign in to comment.