Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add optional allocators
  • Loading branch information
g-bauer committed Jun 17, 2024
commit 9741df0f7792e03ff9c3d9ef7de060caa0f38b17
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ version = "0.21"
features = ["extension-module", "abi3", "abi3-py37"]
optional = true

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

[target.'cfg(all(target_family = "unix", not(allocator = "mimalloc"), not(allocator = "default")))'.dependencies]
tikv-jemallocator = { version = "0.5", features = ["disable_initial_exec_tls"] }

[dev-dependencies]
approx = "0.5"
criterion = "0.5"
Expand Down
29 changes: 29 additions & 0 deletions src/allocator.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#[cfg(all(
target_family = "unix",
not(allocator = "default"),
not(allocator = "mimalloc"),
))]
use tikv_jemallocator::Jemalloc;
#[cfg(all(
not(debug_assertions),
not(allocator = "default"),
any(not(target_family = "unix"), allocator = "mimalloc"),
))]
use mimalloc::MiMalloc;

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

#[global_allocator]
#[cfg(all(
not(debug_assertions),
not(allocator = "default"),
any(not(target_family = "unix"), allocator = "mimalloc"),
))]
static ALLOC: MiMalloc = MiMalloc;
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#![warn(clippy::all)]
#![allow(clippy::too_many_arguments)]

mod allocator;
#[cfg(feature = "dft")]
mod functional;
#[cfg(feature = "dft")]
Expand Down