diff --git a/Cargo.lock b/Cargo.lock index 185003693cd..da46091539a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3935,6 +3935,16 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa" +[[package]] +name = "libmimalloc-sys" +version = "0.1.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23aa6811d3bd4deb8a84dde645f943476d13b248d818edcf8ce0b2f37f036b44" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "libp2p-identity" version = "0.2.9" @@ -4113,6 +4123,15 @@ dependencies = [ "syn 2.0.87", ] +[[package]] +name = "mimalloc" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68914350ae34959d83f732418d51e2427a794055d0b9529f48259ac07af65633" +dependencies = [ + "libmimalloc-sys", +] + [[package]] name = "mime" version = "0.3.17" @@ -4869,6 +4888,7 @@ dependencies = [ "indicatif", "indoc", "miette", + "mimalloc", "minicbor", "mockito", "nix 0.29.0", @@ -7305,6 +7325,7 @@ name = "stress-test" version = "0.1.0" dependencies = [ "clap", + "mimalloc", "ockam", "ockam_api", "ockam_core", diff --git a/implementations/rust/ockam/ockam_command/Cargo.toml b/implementations/rust/ockam/ockam_command/Cargo.toml index 4095e79d1f3..cc7a4c46cea 100644 --- a/implementations/rust/ockam/ockam_command/Cargo.toml +++ b/implementations/rust/ockam/ockam_command/Cargo.toml @@ -63,6 +63,7 @@ hex = "0.4" indicatif = "0.17.8" indoc = "2.0.5" miette = { version = "7.2.0", features = ["fancy-no-backtrace"] } +mimalloc = { version = "0.1", features = ["secure"] } minicbor = { version = "0.25.1", default-features = false, features = ["alloc", "derive"] } nix = { version = "0.29", features = ["signal"] } ockam = { path = "../ockam", version = "^0.141.0", features = ["software_vault"] } diff --git a/implementations/rust/ockam/ockam_command/src/bin/ockam.rs b/implementations/rust/ockam/ockam_command/src/bin/ockam.rs index b5169010620..04d273d49b3 100644 --- a/implementations/rust/ockam/ockam_command/src/bin/ockam.rs +++ b/implementations/rust/ockam/ockam_command/src/bin/ockam.rs @@ -2,8 +2,12 @@ // binary names. The issue is that we need to avoid the `ockam` binary colliding // with the `ockam` crate. +use mimalloc::MiMalloc; use ockam_command::util::exitcode; +#[global_allocator] +static GLOBAL: MiMalloc = MiMalloc; + fn main() { if let Err(e) = ockam_command::entry_point::run() { // initialization errors are displayed here diff --git a/tools/stress-test/Cargo.toml b/tools/stress-test/Cargo.toml index 0e56f027c11..47a5086b437 100644 --- a/tools/stress-test/Cargo.toml +++ b/tools/stress-test/Cargo.toml @@ -13,6 +13,7 @@ rust-crypto = ["ockam/rust-crypto"] [dependencies] clap = { version = "4.5", features = ["derive", "cargo"] } +mimalloc = { version = "0.1", features = ["secure"] } ockam = { path = "../../implementations/rust/ockam/ockam" } ockam_api = { path = "../../implementations/rust/ockam/ockam_api" } ockam_core = { path = "../../implementations/rust/ockam/ockam_core" } diff --git a/tools/stress-test/src/main.rs b/tools/stress-test/src/main.rs index 135c98febf8..410565202dc 100644 --- a/tools/stress-test/src/main.rs +++ b/tools/stress-test/src/main.rs @@ -23,6 +23,11 @@ mod execution; mod portal_simulator; mod stats; +use mimalloc::MiMalloc; + +#[global_allocator] +static GLOBAL: MiMalloc = MiMalloc; + #[derive(Debug, Args, Clone)] struct RunCommand { config: PathBuf,