Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: Add mimalloc feature to tikv_alloc #5041

Merged
merged 9 commits into from Jul 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 21 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Expand Up @@ -15,6 +15,7 @@ publish = false
default = ["tikv_alloc/default"]
tcmalloc = ["tikv_alloc/tcmalloc"]
jemalloc = ["tikv_alloc/jemalloc"]
mimalloc = ["tikv_alloc/mimalloc"]
portable = ["engine/portable"]
sse = ["engine/sse"]
mem-profiling = ["tikv_alloc/mem-profiling"]
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Expand Up @@ -37,6 +37,8 @@ ENABLE_FEATURES ?=
# Pick an allocator
ifeq ($(TCMALLOC),1)
ENABLE_FEATURES += tcmalloc
else ifeq ($(MIMALLOC),1)
ENABLE_FEATURES += mimalloc
else ifeq ($(SYSTEM_ALLOC),1)
# no feature needed for system allocator
else
Expand Down
5 changes: 5 additions & 0 deletions components/tikv_alloc/Cargo.toml
Expand Up @@ -12,6 +12,7 @@ jemalloc = ["jemallocator", "jemalloc-sys", "jemalloc-ctl"]
# Build jemalloc's profiling features. Without this
# certain profile functions will return nothing.
mem-profiling = ["jemallocator/profiling"]
mimalloc = ["mimallocator"]

[dependencies]
libc = "0.2"
Expand Down Expand Up @@ -44,3 +45,7 @@ optional = true
version = "0.3.0"
optional = true
features = ["bundled"]

[dependencies.mimallocator]
version = "0.1.3"
optional = true
9 changes: 8 additions & 1 deletion components/tikv_alloc/src/lib.rs
Expand Up @@ -96,7 +96,14 @@ mod imp;
#[cfg(all(unix, not(fuzzing), feature = "tcmalloc"))]
#[path = "tcmalloc.rs"]
mod imp;
#[cfg(not(all(unix, not(fuzzing), any(feature = "jemalloc", feature = "tcmalloc"))))]
#[cfg(all(unix, not(fuzzing), feature = "mimalloc"))]
#[path = "mimalloc.rs"]
mod imp;
#[cfg(not(all(
unix,
not(fuzzing),
any(feature = "jemalloc", feature = "tcmalloc", feature = "mimalloc")
)))]
#[path = "system.rs"]
mod imp;

Expand Down
7 changes: 7 additions & 0 deletions components/tikv_alloc/src/mimalloc.rs
@@ -0,0 +1,7 @@
pub use crate::default::*;

pub type Allocator = mimallocator::Mimalloc;

pub const fn allocator() -> Allocator {
mimallocator::Mimalloc
}