Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

perf(host-core): integrate mimalloc as global memory allocator

Totopo27cc5a7bbb208c
diff --git a/Cargo.lock b/Cargo.lock
index e8dd04394..b01297d59 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -601,6 +601,7 @@ dependencies = [
"hex",
"ignore",
"libc",
+ "mimalloc",
"rand",
"regex",
"reqwest",
@@ -924,6 +925,15 @@ version = "0.2.189"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2"
+[[package]]
+name = "libmimalloc-sys"
+version = "0.1.49"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6a45a52f43e1c16f667ccfe4dd8c85b7f7c204fd5e3bf46c5b0db9a5c3c0b8e9"
+dependencies = [
+ "cc",
+]
+
[[package]]
name = "libredox"
version = "0.1.20"
@@ -992,6 +1002,15 @@ version = "2.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
+[[package]]
+name = "mimalloc"
+version = "0.1.52"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2d4139bb28d14ad1facf21d5eb8825051b326e172d216b39f6d31df53cc97862"
+dependencies = [
+ "libmimalloc-sys",
+]
+
[[package]]
name = "mio"
version = "1.2.2"
diff --git a/crates/host-core/Cargo.toml b/crates/host-core/Cargo.toml
index bf682c542..87a4665cc 100644
--- a/crates/host-core/Cargo.toml
+++ b/crates/host-core/Cargo.toml
@@ -26,6 +26,7 @@ thiserror = "2"
tokio = { version = "1", features = ["full"] }
uuid = { version = "1", features = ["v4", "serde"] }
walkdir = "2"
+mimalloc = { version = "0.1", default-features = false }
aes-gcm = "0.11"
argon2 = "0.5"
rand = "0.10"
diff --git a/crates/host-core/src/main.rs b/crates/host-core/src/main.rs
index bc94a224c..ceaf188cc 100644
--- a/crates/host-core/src/main.rs
+++ b/crates/host-core/src/main.rs
@@ -38,6 +38,9 @@ use tracing_subscriber::EnvFilter;
use crate::state::AppState;
+#[global_allocator]
+static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
+
#[tokio::main]
async fn main() -> anyhow::Result<()> {
if std::env::args().any(|arg| arg == tools::INTERNAL_TOOL_RUNNER_FLAG) {