diff --git a/CHANGELOG.md b/CHANGELOG.md index 8019065b8..00d3c8c50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ Bob versions changelog ## [Unreleased] #### Added - + - Added mimalloc allocator for musl target (#688) #### Changed diff --git a/bob-apps/Cargo.toml b/bob-apps/Cargo.toml index 4ba024e92..66fb8b28f 100644 --- a/bob-apps/Cargo.toml +++ b/bob-apps/Cargo.toml @@ -4,6 +4,11 @@ version = "2.0.14-alpha.4" authors = ["Kirill Bushminkin ", "Pavel Iakushin "] edition = "2018" +[features] +default = ["mimalloc"] +mimalloc = ["dep:mimalloc"] +mimalloc-secure = ["dep:mimalloc", "mimalloc/secure"] + [dependencies] anyhow = "1.0" async-trait = "0.1" @@ -44,6 +49,9 @@ version = "1.14" default-features = false features = [] +[target.'cfg(all(target_env = "musl", target_arch = "x86_64", target_pointer_width = "64"))'.dependencies] +mimalloc = { version = "0.1", default-features = false, optional = true } + [build-dependencies] tonic-build = "0.6" diff --git a/bob-apps/bin/alloc/mimalloc.rs b/bob-apps/bin/alloc/mimalloc.rs new file mode 100644 index 000000000..b7915ad1f --- /dev/null +++ b/bob-apps/bin/alloc/mimalloc.rs @@ -0,0 +1,16 @@ +#[cfg(all( + any(feature = "mimalloc", feature = "mimalloc-secure"), + target_arch = "x86_64", + target_env = "musl", + target_pointer_width = "64" +))] +use mimalloc::MiMalloc; + +#[cfg(all( + any(feature = "mimalloc", feature = "mimalloc-secure"), + target_arch = "x86_64", + target_env = "musl", + target_pointer_width = "64" +))] +#[global_allocator] +static GLOBAL: MiMalloc = MiMalloc; diff --git a/bob-apps/bin/bobd.rs b/bob-apps/bin/bobd.rs index d955ad9a1..584b7fb76 100755 --- a/bob-apps/bin/bobd.rs +++ b/bob-apps/bin/bobd.rs @@ -1,3 +1,5 @@ +include!("alloc/mimalloc.rs"); + use bob::{ build_info::BuildInfo, init_counters, BobApiServer, BobServer, ClusterConfig, Factory, Grinder, VirtualMapper,