Skip to content

Commit

Permalink
Merge pull request #1649 from input-output-hk/jpraynaud/1629-fix-memo…
Browse files Browse the repository at this point in the history
…ry-fragmentation

Use new memory allocator 'jemallocator'
  • Loading branch information
jpraynaud committed Apr 25, 2024
2 parents 188d8b7 + e471596 commit fa2287d
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ As a minor extension, we have adopted a slightly different versioning convention
- `portable` feature now has no effect and should be removed from crate dependencies.
- Removed it from all other crates (including `mithril-common`).

- 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).

- Crates versions:

| Crate | Version |
Expand Down
26 changes: 24 additions & 2 deletions Cargo.lock

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

8 changes: 7 additions & 1 deletion mithril-aggregator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mithril-aggregator"
version = "0.4.61"
version = "0.4.62"
description = "A Mithril Aggregator server"
authors = { workspace = true }
edition = { workspace = true }
Expand Down Expand Up @@ -46,6 +46,9 @@ uuid = { version = "1.7.0", features = ["v4", "fast-rng", "macro-diagnostics"] }
warp = "0.3.6"
zstd = { version = "0.13.0", features = ["zstdmt"] }

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

[dev-dependencies]
httpmock = "0.7.0"
mithril-common = { path = "../mithril-common", features = [
Expand All @@ -57,4 +60,7 @@ slog-term = "2.9.0"
tempfile = "3.9.0"

[features]
default = ["jemallocator"]

bundle_openssl = ["dep:openssl", "dep:openssl-probe"]
jemallocator = ["dep:tikv-jemallocator"]
8 changes: 8 additions & 0 deletions mithril-aggregator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ pub use tools::{
#[cfg(test)]
pub use dependency_injection::tests::initialize_dependencies;

// Memory allocator (to handle properly memory fragmentation)
#[cfg(all(not(target_env = "msvc"), feature = "jemallocator"))]
use tikv_jemallocator::Jemalloc;

#[cfg(all(not(target_env = "msvc"), feature = "jemallocator"))]
#[global_allocator]
static GLOBAL: Jemalloc = Jemalloc;

#[cfg(test)]
pub(crate) mod test_tools {
use slog::Drain;
Expand Down
8 changes: 7 additions & 1 deletion mithril-signer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mithril-signer"
version = "0.2.125"
version = "0.2.126"
description = "A Mithril Signer"
authors = { workspace = true }
edition = { workspace = true }
Expand Down Expand Up @@ -38,6 +38,9 @@ sqlite = { version = "0.34.0", features = ["bundled"] }
thiserror = "1.0.56"
tokio = { version = "1.35.1", features = ["full"] }

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

[dev-dependencies]
httpmock = "0.7.0"
mithril-common = { path = "../mithril-common" }
Expand All @@ -46,4 +49,7 @@ prometheus-parse = "0.2.5"
slog-term = "2.9.0"

[features]
default = ["jemallocator"]

bundle_openssl = ["dep:openssl", "dep:openssl-probe"]
jemallocator = ["dep:tikv-jemallocator"]
8 changes: 8 additions & 0 deletions mithril-signer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ const HTTP_REQUEST_TIMEOUT_DURATION: u64 = 30000;
const SQLITE_FILE: &str = "signer.sqlite3";
const SQLITE_FILE_CARDANO_TRANSACTION: &str = "cardano-transaction.sqlite3";

// Memory allocator (to handle properly memory fragmentation)
#[cfg(all(not(target_env = "msvc"), feature = "jemallocator"))]
use tikv_jemallocator::Jemalloc;

#[cfg(all(not(target_env = "msvc"), feature = "jemallocator"))]
#[global_allocator]
static GLOBAL: Jemalloc = Jemalloc;

#[cfg(test)]
pub mod test_tools {
use slog::Drain;
Expand Down

0 comments on commit fa2287d

Please sign in to comment.