mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-07-01 13:29:06 +02:00
Add jemalloc and jemalloc-auto features
Introduce the new features jemalloc (set jemalloc global allocator unconditionally) and jemalloc-auto (set jemalloc global allocator on musl-based targets to fix multithreaded performance, see [1]). Because cargo does not support target-specific features or feature defaults, the default is handled using a helper crate minedmap-default-alloc. [1] https://nickb.dev/blog/default-musl-allocator-considered-harmful-to-performance/
This commit is contained in:
parent
a25b3cdbd7
commit
1d9be9a41c
6 changed files with 77 additions and 1 deletions
17
crates/default-alloc/Cargo.toml
Normal file
17
crates/default-alloc/Cargo.toml
Normal file
|
@ -0,0 +1,17 @@
|
|||
[package]
|
||||
name = "minedmap-default-alloc"
|
||||
version = "0.1.0"
|
||||
description = "Helper crate for target-specific selection of global allocator default"
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
readme.workspace = true
|
||||
repository.workspace = true
|
||||
|
||||
[dependencies]
|
||||
tikv-jemallocator = { version = "0.6.0", optional = true }
|
||||
|
||||
[target.'cfg(target_env = "musl")'.dependencies]
|
||||
tikv-jemallocator = "*"
|
||||
|
||||
[features]
|
||||
jemalloc = ["dep:tikv-jemallocator"]
|
3
crates/default-alloc/src/lib.rs
Normal file
3
crates/default-alloc/src/lib.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
#[cfg(any(target_env = "musl", feature = "jemalloc"))]
|
||||
#[global_allocator]
|
||||
static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
|
Loading…
Add table
Add a link
Reference in a new issue