Skip to content

Commit

Permalink
668 allocator backport (#737)
Browse files Browse the repository at this point in the history
* Backport 688 allocator

* Add changelog message
  • Loading branch information
lostl1ght authored Jan 13, 2023
1 parent 1cec98b commit b10c981
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Bob versions changelog

## [Unreleased]
#### Added

- Added mimalloc allocator for musl target (#688)

#### Changed

Expand Down
8 changes: 8 additions & 0 deletions bob-apps/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ version = "2.0.14-alpha.4"
authors = ["Kirill Bushminkin <kb@qoollo.com>", "Pavel Iakushin <pyakushin@qoollo.com>"]
edition = "2018"

[features]
default = ["mimalloc"]
mimalloc = ["dep:mimalloc"]
mimalloc-secure = ["dep:mimalloc", "mimalloc/secure"]

[dependencies]
anyhow = "1.0"
async-trait = "0.1"
Expand Down Expand Up @@ -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"

Expand Down
16 changes: 16 additions & 0 deletions bob-apps/bin/alloc/mimalloc.rs
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 2 additions & 0 deletions bob-apps/bin/bobd.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
include!("alloc/mimalloc.rs");

use bob::{
build_info::BuildInfo, init_counters, BobApiServer, BobServer, ClusterConfig, Factory, Grinder,
VirtualMapper,
Expand Down

0 comments on commit b10c981

Please sign in to comment.