Skip to content

Commit fa2287d

Browse files
authored
Merge pull request #1649 from input-output-hk/jpraynaud/1629-fix-memory-fragmentation
Use new memory allocator 'jemallocator'
2 parents 188d8b7 + e471596 commit fa2287d

File tree

6 files changed

+56
-4
lines changed

6 files changed

+56
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ As a minor extension, we have adopted a slightly different versioning convention
2222
- `portable` feature now has no effect and should be removed from crate dependencies.
2323
- Removed it from all other crates (including `mithril-common`).
2424

25+
- Switched memory allocator to `jemallocator` on signer and aggregator to avoid memory fragmentation when signing transactions (which lead to RES memory not being properly returned to the OS).
26+
2527
- Crates versions:
2628

2729
| Crate | Version |

Cargo.lock

Lines changed: 24 additions & 2 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: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithril-aggregator"
3-
version = "0.4.61"
3+
version = "0.4.62"
44
description = "A Mithril Aggregator server"
55
authors = { workspace = true }
66
edition = { workspace = true }
@@ -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;

mithril-signer/Cargo.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithril-signer"
3-
version = "0.2.125"
3+
version = "0.2.126"
44
description = "A Mithril Signer"
55
authors = { workspace = true }
66
edition = { workspace = true }
@@ -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)