Skip to content

Commit

Permalink
fix: use new memory allocator 'jemallocator'
Browse files Browse the repository at this point in the history
This will likely avoid having memory fragmentation resulting in RES memory not being correctly released.
  • Loading branch information
jpraynaud committed Apr 22, 2024
1 parent d415b23 commit f9d2c10
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
21 changes: 21 additions & 0 deletions Cargo.lock

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

6 changes: 5 additions & 1 deletion mithril-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ mithril-stm = { path = "../mithril-stm", version = "0.3", default-features = fal
] }
wasm-bindgen = "0.2.90"

[target.'cfg(not(target_env = "msvc"))'.dependencies]
tikv-jemallocator = { version = "0.5.4", optional = true }

[dev-dependencies]
criterion = { version = "0.5.1", features = ["html_reports", "async_tokio"] }
mockall = "0.12.1"
Expand All @@ -104,7 +107,7 @@ mithril-build-script = { path = "../internal/mithril-build-script", version = "=
default = []

# Full feature set
full = ["random", "fs", "test_tools"]
full = ["random", "fs", "test_tools", "jemallocator"]
random = ["rand_core/getrandom"]
fs = [
"tokio/fs",
Expand All @@ -116,6 +119,7 @@ fs = [
"dep:pallas-primitives",
"dep:pallas-traverse",
]
jemallocator = ["dep:tikv-jemallocator"]

# Disable signer certification, to be used only for tests
allow_skip_signer_certification = []
Expand Down
17 changes: 17 additions & 0 deletions mithril-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ macro_rules! cfg_test_tools {
}
}

macro_rules! cfg_jemallocator {
($($item:item)*) => {
$(
#[cfg(all(not(target_env = "msvc"), feature = "jemallocator"))]
$item
)*
}
}

pub mod api_version;
pub mod certificate_chain;
pub mod chain_observer;
Expand Down Expand Up @@ -86,3 +95,11 @@ pub const MITHRIL_API_VERSION_HEADER: &str = "mithril-api-version";

/// Mithril Signer node version header name
pub const MITHRIL_SIGNER_VERSION_HEADER: &str = "signer-node-version";

// Memory allocator
cfg_jemallocator! {
use tikv_jemallocator::Jemalloc;

#[global_allocator]
static GLOBAL: Jemalloc = Jemalloc;
}

0 comments on commit f9d2c10

Please sign in to comment.