Skip to content

Commit

Permalink
build: Use default allocator for lts-cpu (#15941)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 authored Apr 28, 2024
1 parent 031c926 commit c1474f6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ jobs:
if: matrix.architecture == 'x86-64'
env:
FEATURES: ${{ steps.features.outputs.features }}
CFG: ${{ matrix.package == 'polars-lts-cpu' && '--cfg use_mimalloc' || '' }}
CFG: ${{ matrix.package == 'polars-lts-cpu' && '--cfg default_allocator' || '' }}
run: echo "RUSTFLAGS=-C target-feature=${{ steps.features.outputs.features }} $CFG" >> $GITHUB_ENV

- name: Set variables in CPU check module
Expand Down
4 changes: 2 additions & 2 deletions py-polars/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ features = [
built = { version = "0.7", features = ["chrono", "git2", "cargo-lock"], optional = true }

[target.'cfg(any(not(target_family = "unix"), use_mimalloc))'.dependencies]
mimalloc = { version = "=0.1.39", default-features = false }
mimalloc = { version = "0.1", default-features = false }

[target.'cfg(all(target_family = "unix", not(use_mimalloc)))'.dependencies]
[target.'cfg(all(target_family = "unix", not(use_mimalloc), not(default_allocator)))'.dependencies]
jemallocator = { version = "0.5", features = ["disable_initial_exec_tls"] }

# features are only there to enable building a slim binary for the benchmark in CI
Expand Down
15 changes: 12 additions & 3 deletions py-polars/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,24 @@ use crate::sql::PySQLContext;
// linking breaks on Windows if we use tracemalloc C APIs. So we only use this
// on Windows for now.
#[global_allocator]
#[cfg(all(target_family = "unix", debug_assertions))]
#[cfg(all(target_family = "unix", debug_assertions, not(default_allocator)))]
static ALLOC: TracemallocAllocator<Jemalloc> = TracemallocAllocator::new(Jemalloc);

#[global_allocator]
#[cfg(all(target_family = "unix", not(use_mimalloc), not(debug_assertions)))]
#[cfg(all(
target_family = "unix",
not(use_mimalloc),
not(debug_assertions),
not(default_allocator)
))]
static ALLOC: Jemalloc = Jemalloc;

#[global_allocator]
#[cfg(all(any(not(target_family = "unix"), use_mimalloc), not(debug_assertions)))]
#[cfg(all(
any(not(target_family = "unix"), use_mimalloc),
not(debug_assertions),
not(default_allocator)
))]
static ALLOC: MiMalloc = MiMalloc;

#[pymodule]
Expand Down

0 comments on commit c1474f6

Please sign in to comment.