alloc: use jemalloc when building with musl

It turns out that musl's allocator is slow enough to cause a fairly
noticeable performance regression when ripgrep is built as a static
binary with musl. We fix this by using jemalloc when building with musl.

We continue to use the default system allocator in all other scenarios.
Namely, glibc's allocator doesn't noticeably regress performance compared
to jemalloc. But we could add more targets to this logic if other
system allocators (macOS, Windows) prove to be slow.

This wasn't necessary before because rustc recently stopped using jemalloc
by default.

Fixes #1268
This commit is contained in:
Andrew Gallant
2019-04-24 17:21:38 -04:00
parent e7829c05d3
commit 03bf37ff4a
3 changed files with 51 additions and 0 deletions

View File

@@ -61,6 +61,9 @@ version = "2.32.0"
default-features = false
features = ["suggestions"]
[target.'cfg(target_env = "musl")'.dependencies.jemallocator]
version = "0.3.0"
[build-dependencies]
lazy_static = "1.1.0"