From 624600e2f1f50b76e0d065a8720b6a09bf55d3d5 Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 26 Mar 2024 10:33:01 -0500 Subject: [PATCH] Add mimalloc for windows --- .github/workflows/release.yml | 2 +- Cargo.lock | 20 ++++++++++++++++++++ Cargo.toml | 5 ++++- src/main.rs | 4 ++++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5cffcfe..cf97754 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -44,7 +44,7 @@ jobs: - os: macos cargoargs: --features build-cranelift,jemalloc - os: windows - cargoargs: --features build-cranelift + cargoargs: --features build-cranelift,mimalloc steps: - uses: actions/checkout@v2 diff --git a/Cargo.lock b/Cargo.lock index 75b64d7..b4b486a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1358,6 +1358,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "libmimalloc-sys" +version = "0.1.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3979b5c37ece694f1f5e51e7ecc871fdb0f517ed04ee45f88d15d6d553cb9664" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "libredox" version = "0.0.1" @@ -1514,6 +1524,15 @@ dependencies = [ "autocfg", ] +[[package]] +name = "mimalloc" +version = "0.1.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa01922b5ea280a911e323e4d2fd24b7fe5cc4042e0d2cda3c40775cdc4bdc9c" +dependencies = [ + "libmimalloc-sys", +] + [[package]] name = "mime" version = "0.3.17" @@ -2222,6 +2241,7 @@ dependencies = [ "log", "logic", "maplit", + "mimalloc", "native-runner", "once_cell", "owning_ref", diff --git a/Cargo.toml b/Cargo.toml index ca21d99..1acfc81 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,7 @@ name = "rumblebot" version = "0.1.0" authors = ["Anton ", "Noa "] edition = "2018" +mutually_exclusive_features = ["jemalloc", "mimalloc"] [dependencies] logic = { path = "../logic/logic" } @@ -53,12 +54,14 @@ textwrap = { version = "0.16", default-features = false } sentry = "0.32.2" jemallocator = { version = "0.5.4", optional = true } +mimalloc = { version = "*", default-features = false, optional = true } [features] -default = ["build-cranelift", "jemallocator"] +default = ["build-cranelift", "jemalloc"] build-cranelift = ["wasmer-compiler-cranelift"] build-llvm = ["wasmer-compiler-llvm", "inkwell", "llvm-sys-120"] jemalloc = ["jemallocator"] +mimalloc = ["dep:mimalloc"] [build-dependencies] wasmer = { version = "2.0", default-features = false, features = ["universal"] } diff --git a/src/main.rs b/src/main.rs index 0401fb7..15b7360 100644 --- a/src/main.rs +++ b/src/main.rs @@ -30,6 +30,10 @@ mod server; #[global_allocator] static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; +#[cfg(feature = "mimalloc")] +#[global_allocator] +static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; + #[tokio::main] async fn main() { env_logger::init();