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:
Matthias Schiffer 2025-02-12 20:22:26 +01:00
parent a25b3cdbd7
commit 1d9be9a41c
Signed by: neocturne
GPG key ID: 16EF3F64CB201D9C
6 changed files with 77 additions and 1 deletions

28
Cargo.lock generated
View file

@ -591,6 +591,7 @@ dependencies = [
"image",
"indexmap",
"lru",
"minedmap-default-alloc",
"minedmap-nbt",
"minedmap-resource",
"minedmap-types",
@ -608,6 +609,13 @@ dependencies = [
"zstd",
]
[[package]]
name = "minedmap-default-alloc"
version = "0.1.0"
dependencies = [
"tikv-jemallocator",
]
[[package]]
name = "minedmap-nbt"
version = "0.1.1"
@ -1057,6 +1065,26 @@ dependencies = [
"once_cell",
]
[[package]]
name = "tikv-jemalloc-sys"
version = "0.6.0+5.3.0-1-ge13ca993e8ccb9ba9847cc330696e02839f328f7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd3c60906412afa9c2b5b5a48ca6a5abe5736aec9eb48ad05037a677e52e4e2d"
dependencies = [
"cc",
"libc",
]
[[package]]
name = "tikv-jemallocator"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4cec5ff18518d81584f477e9bfdf957f5bb0979b0bac3af4ca30b5b3ae2d2865"
dependencies = [
"libc",
"tikv-jemalloc-sys",
]
[[package]]
name = "tokio"
version = "1.43.0"