diff --git a/Cargo.lock b/Cargo.lock index 89287609a2..5755367131 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -94,6 +94,7 @@ dependencies = [ "proptest", "rand", "thiserror", + "tikv-jemallocator", "toml", "tracing-appender", "tracing-subscriber", @@ -3052,6 +3053,7 @@ dependencies = [ "termion", "test-case", "thiserror", + "tikv-jemallocator", "tokio", "tokio-util", "toml", @@ -3221,6 +3223,7 @@ dependencies = [ "serde", "serde_json", "tempfile", + "tikv-jemallocator", "tracing-appender", "tracing-subscriber", ] @@ -5075,6 +5078,26 @@ dependencies = [ "once_cell", ] +[[package]] +name = "tikv-jemalloc-sys" +version = "0.5.4+5.3.0-patched" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9402443cb8fd499b6f327e40565234ff34dbda27460c5b47db0db77443dd85d1" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "tikv-jemallocator" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "965fe0c26be5c56c94e38ba547249074803efd52adfb66de62107d95aab3eaca" +dependencies = [ + "libc", + "tikv-jemalloc-sys", +] + [[package]] name = "time" version = "0.3.36" diff --git a/Cargo.toml b/Cargo.toml index 567f1db085..2383079ae6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -168,6 +168,8 @@ tracing-web = "0.1.3" tracing-subscriber = { version = "0.3.18", features = ["env-filter", "json"] } rust-embed = "6.6.0" +tikv-jemallocator = "0.5" + [profile.dev] # This is required to be able to run `cargo test` in acvm_js due to the `locals exceeds maximum` error. # See https://ritik-mishra.medium.com/resolving-the-wasm-pack-error-locals-exceed-maximum-ec3a9d96685b diff --git a/tooling/acvm_cli/Cargo.toml b/tooling/acvm_cli/Cargo.toml index 06dd5e676b..0166a130b7 100644 --- a/tooling/acvm_cli/Cargo.toml +++ b/tooling/acvm_cli/Cargo.toml @@ -31,6 +31,9 @@ const_format.workspace = true bn254_blackbox_solver.workspace = true acir.workspace = true +[target.'cfg(not(target_env = "msvc"))'.dependencies] +tikv-jemallocator.workspace = true + # Logs tracing-subscriber.workspace = true tracing-appender = "0.2.3" diff --git a/tooling/acvm_cli/src/main.rs b/tooling/acvm_cli/src/main.rs index 33cadc73a7..5a72555c79 100644 --- a/tooling/acvm_cli/src/main.rs +++ b/tooling/acvm_cli/src/main.rs @@ -11,6 +11,13 @@ use std::env; use tracing_appender::rolling; use tracing_subscriber::{fmt::format::FmtSpan, EnvFilter}; +#[cfg(not(target_env = "msvc"))] +use tikv_jemallocator::Jemalloc; + +#[cfg(not(target_env = "msvc"))] +#[global_allocator] +static GLOBAL: Jemalloc = Jemalloc; + fn main() { // Setup tracing if let Ok(log_dir) = env::var("ACVM_LOG_DIR") { diff --git a/tooling/nargo_cli/Cargo.toml b/tooling/nargo_cli/Cargo.toml index 001306bb16..62bd00e577 100644 --- a/tooling/nargo_cli/Cargo.toml +++ b/tooling/nargo_cli/Cargo.toml @@ -77,6 +77,9 @@ tracing-appender = "0.2.3" clap_complete = "4.5.36" fs2 = "0.4.3" +[target.'cfg(not(target_env = "msvc"))'.dependencies] +tikv-jemallocator.workspace = true + [target.'cfg(not(unix))'.dependencies] tokio-util = { version = "0.7.8", features = ["compat"] } diff --git a/tooling/nargo_cli/src/main.rs b/tooling/nargo_cli/src/main.rs index 3ea167b7ff..d12f719f66 100644 --- a/tooling/nargo_cli/src/main.rs +++ b/tooling/nargo_cli/src/main.rs @@ -19,6 +19,13 @@ use tracing_subscriber::{fmt::format::FmtSpan, EnvFilter}; const PANIC_MESSAGE: &str = "This is a bug. We may have already fixed this in newer versions of Nargo so try searching for similar issues at https://github.com/noir-lang/noir/issues/.\nIf there isn't an open issue for this bug, consider opening one at https://github.com/noir-lang/noir/issues/new?labels=bug&template=bug_report.yml"; +#[cfg(not(target_env = "msvc"))] +use tikv_jemallocator::Jemalloc; + +#[cfg(not(target_env = "msvc"))] +#[global_allocator] +static GLOBAL: Jemalloc = Jemalloc; + fn main() { setup_tracing(); diff --git a/tooling/profiler/Cargo.toml b/tooling/profiler/Cargo.toml index 798a21ea0d..7b853e524a 100644 --- a/tooling/profiler/Cargo.toml +++ b/tooling/profiler/Cargo.toml @@ -39,6 +39,9 @@ noirc_evaluator.workspace = true tracing-subscriber.workspace = true tracing-appender = "0.2.3" +[target.'cfg(not(target_env = "msvc"))'.dependencies] +tikv-jemallocator.workspace = true + [dev-dependencies] noirc_abi.workspace = true noirc_driver.workspace = true diff --git a/tooling/profiler/src/main.rs b/tooling/profiler/src/main.rs index b0b42e6ee4..c2022a8c9d 100644 --- a/tooling/profiler/src/main.rs +++ b/tooling/profiler/src/main.rs @@ -14,6 +14,13 @@ use std::env; use tracing_appender::rolling; use tracing_subscriber::{fmt::format::FmtSpan, EnvFilter}; +#[cfg(not(target_env = "msvc"))] +use tikv_jemallocator::Jemalloc; + +#[cfg(not(target_env = "msvc"))] +#[global_allocator] +static GLOBAL: Jemalloc = Jemalloc; + fn main() { // Setup tracing if let Ok(log_dir) = env::var("PROFILER_LOG_DIR") {