From ffaea4be2c72cec1fdaf4a4a17d4e5f7b9635d4a Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 26 Mar 2024 09:40:49 -0500 Subject: [PATCH] Add Jemalloc --- Cargo.lock | 21 +++++++++++++++++++++ Cargo.toml | 1 + src/main.rs | 7 +++---- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a843e4b..75b64d7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1279,6 +1279,26 @@ version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +[[package]] +name = "jemalloc-sys" +version = "0.5.4+5.3.0-patched" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac6c1946e1cea1788cbfde01c993b52a10e2da07f4bac608228d1bed20bfebf2" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "jemallocator" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0de374a9f8e63150e6f5e8a60cc14c668226d7a347d8aee1a45766e3c4dd3bc" +dependencies = [ + "jemalloc-sys", + "libc", +] + [[package]] name = "jni" version = "0.21.1" @@ -2197,6 +2217,7 @@ dependencies = [ "futures-util", "inkwell", "itertools 0.12.1", + "jemallocator", "llvm-sys", "log", "logic", diff --git a/Cargo.toml b/Cargo.toml index 1aa2412..ce09daf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,6 +52,7 @@ termcolor = "1.4" textwrap = { version = "0.16", default-features = false } sentry = "0.32.2" +jemallocator = "0.5.4" [features] default = ["build-cranelift"] diff --git a/src/main.rs b/src/main.rs index 470bccb..085ecbc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -26,6 +26,9 @@ mod api; mod display; mod server; +#[global_allocator] +static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; + #[tokio::main] async fn main() { env_logger::init(); @@ -288,7 +291,6 @@ impl Runner { let (module, version) = lang.get_wasm(store)?; // This is very strange, but this exactly println in this exact place is necessary to avoid // error: "corrupted binary: misaligned metadata" - println!("IT worked"); Runner::new_wasm(store, module, version, &[], sourcedir).await } RobotId::Command { command, args } => { @@ -638,9 +640,6 @@ impl Lang { }}; } let lang = self; - // This is very strange, but this exactly println in this exact place is necessary to avoid - // error: "corrupted binary: misaligned metadata" - println!("ATTEMPTING"); Ok(include!(concat!(env!("OUT_DIR"), "/lang_runners.rs"))) } }