Skip to content

Commit b18bed9

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

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

Cargo.lock

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

mithril-signer/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ sqlite = { version = "0.34.0", features = ["bundled"] }
3838
thiserror = "1.0.56"
3939
tokio = { version = "1.35.1", features = ["full"] }
4040

41+
[target.'cfg(not(target_env = "msvc"))'.dependencies]
42+
tikv-jemallocator = { version = "0.5.4", optional = true }
43+
4144
[dev-dependencies]
4245
httpmock = "0.7.0"
4346
mithril-common = { path = "../mithril-common" }
@@ -46,4 +49,7 @@ prometheus-parse = "0.2.5"
4649
slog-term = "2.9.0"
4750

4851
[features]
52+
default = ["jemallocator"]
53+
4954
bundle_openssl = ["dep:openssl", "dep:openssl-probe"]
55+
jemallocator = ["dep:tikv-jemallocator"]

mithril-signer/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ const HTTP_REQUEST_TIMEOUT_DURATION: u64 = 30000;
3636
const SQLITE_FILE: &str = "signer.sqlite3";
3737
const SQLITE_FILE_CARDANO_TRANSACTION: &str = "cardano-transaction.sqlite3";
3838

39+
// Memory allocator (to handle properly memory fragmentation)
40+
#[cfg(all(not(target_env = "msvc"), feature = "jemallocator"))]
41+
use tikv_jemallocator::Jemalloc;
42+
43+
#[cfg(all(not(target_env = "msvc"), feature = "jemallocator"))]
44+
#[global_allocator]
45+
static GLOBAL: Jemalloc = Jemalloc;
46+
3947
#[cfg(test)]
4048
pub mod test_tools {
4149
use slog::Drain;

0 commit comments

Comments
 (0)