From df1b4a13f4c3f192d708dddb0c4a54f38c703d8a Mon Sep 17 00:00:00 2001 From: Contsantine Bulany <61948252+lostl1ght@users.noreply.github.com> Date: Thu, 12 Jan 2023 17:59:40 +0300 Subject: [PATCH 1/2] Backport 688 allocator --- bob-apps/Cargo.toml | 8 ++++++++ bob-apps/bin/alloc/mimalloc.rs | 16 ++++++++++++++++ bob-apps/bin/bobd.rs | 2 ++ 3 files changed, 26 insertions(+) create mode 100644 bob-apps/bin/alloc/mimalloc.rs 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, From 14ca678cf75c0807238b4d25a34b701dc4f1f479 Mon Sep 17 00:00:00 2001 From: Contsantine Bulany <61948252+lostl1ght@users.noreply.github.com> Date: Fri, 13 Jan 2023 17:30:29 +0300 Subject: [PATCH 2/2] Add changelog message --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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