diff --git a/Cargo.lock b/Cargo.lock index c8a59fbb4..ab2f6dc5f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1646,6 +1646,16 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "libmimalloc-sys" +version = "0.1.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3979b5c37ece694f1f5e51e7ecc871fdb0f517ed04ee45f88d15d6d553cb9664" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "libredox" version = "0.0.1" @@ -1805,6 +1815,15 @@ dependencies = [ "syn 2.0.39", ] +[[package]] +name = "mimalloc" +version = "0.1.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa01922b5ea280a911e323e4d2fd24b7fe5cc4042e0d2cda3c40775cdc4bdc9c" +dependencies = [ + "libmimalloc-sys", +] + [[package]] name = "mime" version = "0.3.17" @@ -2332,6 +2351,7 @@ dependencies = [ "install-wheel-rs", "itertools 0.11.0", "miette", + "mimalloc", "pep440_rs 0.3.12", "pep508_rs", "platform-host", @@ -2351,6 +2371,7 @@ dependencies = [ "requirements-txt", "tempfile", "thiserror", + "tikv-jemallocator", "tokio", "toml 0.8.8", "tracing", @@ -2403,6 +2424,7 @@ dependencies = [ "gourgeist", "indicatif", "itertools 0.11.0", + "mimalloc", "pep508_rs", "platform-host", "platform-tags", @@ -2413,6 +2435,7 @@ dependencies = [ "puffin-traits", "pypi-types", "tempfile", + "tikv-jemallocator", "tokio", "tracing", "tracing-indicatif", @@ -3535,6 +3558,26 @@ dependencies = [ "once_cell", ] +[[package]] +name = "tikv-jemalloc-sys" +version = "0.5.4+5.3.0-patched" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9402443cb8fd499b6f327e40565234ff34dbda27460c5b47db0db77443dd85d1" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "tikv-jemallocator" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "965fe0c26be5c56c94e38ba547249074803efd52adfb66de62107d95aab3eaca" +dependencies = [ + "libc", + "tikv-jemalloc-sys", +] + [[package]] name = "time" version = "0.3.30" diff --git a/crates/puffin-cli/Cargo.toml b/crates/puffin-cli/Cargo.toml index a4e7ab46d..29795f32d 100644 --- a/crates/puffin-cli/Cargo.toml +++ b/crates/puffin-cli/Cargo.toml @@ -54,6 +54,12 @@ tracing-tree = { workspace = true } url = { workspace = true } which = { workspace = true } +[target.'cfg(target_os = "windows")'.dependencies] +mimalloc = "0.1.39" + +[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 = "0.5.0" + [dev-dependencies] assert_cmd = { version = "2.0.12" } assert_fs = { version = "1.0.13" } diff --git a/crates/puffin-cli/src/main.rs b/crates/puffin-cli/src/main.rs index b2833bb85..6261c209e 100644 --- a/crates/puffin-cli/src/main.rs +++ b/crates/puffin-cli/src/main.rs @@ -18,6 +18,22 @@ use crate::index_urls::IndexUrls; use crate::python_version::PythonVersion; use crate::requirements::RequirementsSource; +#[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 commands; mod index_urls; mod logging; diff --git a/crates/puffin-dev/Cargo.toml b/crates/puffin-dev/Cargo.toml index bbb4261e5..0c99d4f67 100644 --- a/crates/puffin-dev/Cargo.toml +++ b/crates/puffin-dev/Cargo.toml @@ -38,3 +38,9 @@ tracing-indicatif = { workspace = true } tracing-subscriber = { workspace = true } which = { workspace = true } url = { workspace = true } + +[target.'cfg(target_os = "windows")'.dependencies] +mimalloc = "0.1.39" + +[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 = "0.5.0" diff --git a/crates/puffin-dev/src/main.rs b/crates/puffin-dev/src/main.rs index dafe745e8..a701a86c7 100644 --- a/crates/puffin-dev/src/main.rs +++ b/crates/puffin-dev/src/main.rs @@ -18,6 +18,22 @@ use crate::build::{build, BuildArgs}; use crate::resolve_cli::ResolveCliArgs; 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 build; mod resolve_cli; mod resolve_many;