Skip to content

Commit e05ebd2

Browse files
committed
fix: use new memory allocator 'jemallocator' in aggregator
This will likely avoid having memory fragmentation resulting in RES memory not being correctly released.
1 parent b18bed9 commit e05ebd2

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mithril-aggregator/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ uuid = { version = "1.7.0", features = ["v4", "fast-rng", "macro-diagnostics"] }
4646
warp = "0.3.6"
4747
zstd = { version = "0.13.0", features = ["zstdmt"] }
4848

49+
[target.'cfg(not(target_env = "msvc"))'.dependencies]
50+
tikv-jemallocator = { version = "0.5.4", optional = true }
51+
4952
[dev-dependencies]
5053
httpmock = "0.7.0"
5154
mithril-common = { path = "../mithril-common", features = [
@@ -57,4 +60,7 @@ slog-term = "2.9.0"
5760
tempfile = "3.9.0"
5861

5962
[features]
63+
default = ["jemallocator"]
64+
6065
bundle_openssl = ["dep:openssl", "dep:openssl-probe"]
66+
jemallocator = ["dep:tikv-jemallocator"]

mithril-aggregator/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ pub use tools::{
6464
#[cfg(test)]
6565
pub use dependency_injection::tests::initialize_dependencies;
6666

67+
// Memory allocator (to handle properly memory fragmentation)
68+
#[cfg(all(not(target_env = "msvc"), feature = "jemallocator"))]
69+
use tikv_jemallocator::Jemalloc;
70+
71+
#[cfg(all(not(target_env = "msvc"), feature = "jemallocator"))]
72+
#[global_allocator]
73+
static GLOBAL: Jemalloc = Jemalloc;
74+
6775
#[cfg(test)]
6876
pub(crate) mod test_tools {
6977
use slog::Drain;

0 commit comments

Comments
 (0)