about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--tvix/Cargo.lock49
-rw-r--r--tvix/Cargo.nix167
-rw-r--r--tvix/build/Cargo.toml1
-rw-r--r--tvix/build/src/bin/tvix-build.rs5
-rw-r--r--tvix/cli/Cargo.toml4
-rw-r--r--tvix/cli/src/main.rs7
-rw-r--r--tvix/eval/Cargo.toml4
-rw-r--r--tvix/eval/benches/eval.rs6
-rw-r--r--tvix/glue/Cargo.toml4
-rw-r--r--tvix/glue/benches/eval.rs6
-rw-r--r--tvix/nar-bridge/Cargo.toml1
-rw-r--r--tvix/nar-bridge/src/bin/nar-bridge.rs4
-rw-r--r--tvix/nix-compat/Cargo.toml2
-rw-r--r--tvix/nix-compat/benches/derivation_parse_aterm.rs4
-rw-r--r--tvix/nix-compat/benches/narinfo_parse.rs4
-rw-r--r--tvix/nix-compat/src/bin/drvfmt.rs5
-rw-r--r--tvix/store/Cargo.toml1
-rw-r--r--tvix/store/src/bin/tvix-store.rs5
18 files changed, 153 insertions, 126 deletions
diff --git a/tvix/Cargo.lock b/tvix/Cargo.lock
index 8e5c67bc4307..9bea027e4de3 100644
--- a/tvix/Cargo.lock
+++ b/tvix/Cargo.lock
@@ -2074,6 +2074,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058"
 
 [[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 = "libredox"
 version = "0.0.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2223,6 +2233,15 @@ dependencies = [
 ]
 
 [[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"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2273,6 +2292,7 @@ dependencies = [
  "hex-literal",
  "itertools 0.12.0",
  "lru",
+ "mimalloc",
  "nix-compat",
  "parking_lot 0.12.3",
  "prost 0.13.1",
@@ -2365,6 +2385,7 @@ dependencies = [
  "glob",
  "hex-literal",
  "lazy_static",
+ "mimalloc",
  "nom",
  "num-traits",
  "pin-project-lite",
@@ -4149,26 +4170,6 @@ dependencies = [
 ]
 
 [[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.34"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -4780,6 +4781,7 @@ dependencies = [
  "bytes",
  "clap",
  "itertools 0.12.0",
+ "mimalloc",
  "prost 0.13.1",
  "prost-build 0.13.1",
  "rstest",
@@ -4867,6 +4869,7 @@ dependencies = [
  "clap",
  "dirs",
  "expect-test",
+ "mimalloc",
  "nix-compat",
  "rnix",
  "rowan",
@@ -4874,7 +4877,6 @@ dependencies = [
  "rustyline",
  "smol_str",
  "thiserror",
- "tikv-jemallocator",
  "tokio",
  "tracing",
  "tracing-indicatif",
@@ -4904,6 +4906,7 @@ dependencies = [
  "lazy_static",
  "lexical-core",
  "md-5",
+ "mimalloc",
  "os_str_bytes",
  "path-clean",
  "pretty_assertions",
@@ -4921,7 +4924,6 @@ dependencies = [
  "tabwriter",
  "tempfile",
  "test-strategy",
- "tikv-jemallocator",
  "toml 0.6.0",
  "tvix-eval-builtin-macros",
 ]
@@ -4951,6 +4953,7 @@ dependencies = [
  "lazy_static",
  "magic",
  "md-5",
+ "mimalloc",
  "nix 0.27.1",
  "nix-compat",
  "pin-project",
@@ -4963,7 +4966,6 @@ dependencies = [
  "sha2",
  "tempfile",
  "thiserror",
- "tikv-jemallocator",
  "tokio",
  "tokio-tar",
  "tokio-util",
@@ -5007,6 +5009,7 @@ dependencies = [
  "hyper-util",
  "lazy_static",
  "lru",
+ "mimalloc",
  "nix-compat",
  "parking_lot 0.12.3",
  "pin-project-lite",
diff --git a/tvix/Cargo.nix b/tvix/Cargo.nix
index 23539daab988..96101a926475 100644
--- a/tvix/Cargo.nix
+++ b/tvix/Cargo.nix
@@ -6484,6 +6484,32 @@ rec {
         };
         resolvedDefaultFeatures = [ "default" ];
       };
+      "libmimalloc-sys" = rec {
+        crateName = "libmimalloc-sys";
+        version = "0.1.39";
+        edition = "2018";
+        links = "mimalloc";
+        sha256 = "0i3b0dzz7cp0ik7ys66q92r16va78gwlbrnxhj5fnkdxsc8niai3";
+        authors = [
+          "Octavian Oncescu <octavonce@gmail.com>"
+        ];
+        dependencies = [
+          {
+            name = "libc";
+            packageId = "libc";
+          }
+        ];
+        buildDependencies = [
+          {
+            name = "cc";
+            packageId = "cc";
+          }
+        ];
+        features = {
+          "cty" = [ "dep:cty" ];
+          "extended" = [ "cty" ];
+        };
+      };
       "libredox" = rec {
         crateName = "libredox";
         version = "0.0.1";
@@ -6883,6 +6909,34 @@ rec {
         features = { };
         resolvedDefaultFeatures = [ "default" ];
       };
+      "mimalloc" = rec {
+        crateName = "mimalloc";
+        version = "0.1.43";
+        edition = "2018";
+        sha256 = "0csnyrxc16i592gm5ffham07jyj2w98qsh9jyy1rv59lmr8474b8";
+        authors = [
+          "Octavian Oncescu <octavonce@gmail.com>"
+          "Vincent Rouillé <vincent@speedy37.fr>"
+          "Thom Chiovoloni <chiovolonit@gmail.com>"
+        ];
+        dependencies = [
+          {
+            name = "libmimalloc-sys";
+            packageId = "libmimalloc-sys";
+            usesDefaultFeatures = false;
+          }
+        ];
+        features = {
+          "debug" = [ "libmimalloc-sys/debug" ];
+          "debug_in_debug" = [ "libmimalloc-sys/debug_in_debug" ];
+          "extended" = [ "libmimalloc-sys/extended" ];
+          "local_dynamic_tls" = [ "libmimalloc-sys/local_dynamic_tls" ];
+          "no_thp" = [ "libmimalloc-sys/no_thp" ];
+          "override" = [ "libmimalloc-sys/override" ];
+          "secure" = [ "libmimalloc-sys/secure" ];
+        };
+        resolvedDefaultFeatures = [ "default" ];
+      };
       "mime" = rec {
         crateName = "mime";
         version = "0.3.17";
@@ -7036,6 +7090,10 @@ rec {
             packageId = "lru";
           }
           {
+            name = "mimalloc";
+            packageId = "mimalloc";
+          }
+          {
             name = "nix-compat";
             packageId = "nix-compat";
             features = [ "async" ];
@@ -7373,6 +7431,10 @@ rec {
             packageId = "glob";
           }
           {
+            name = "mimalloc";
+            packageId = "mimalloc";
+          }
+          {
             name = "nom";
             packageId = "nom";
           }
@@ -7430,6 +7492,10 @@ rec {
             packageId = "lazy_static";
           }
           {
+            name = "mimalloc";
+            packageId = "mimalloc";
+          }
+          {
             name = "pretty_assertions";
             packageId = "pretty_assertions";
           }
@@ -13059,72 +13125,6 @@ rec {
         ];
 
       };
-      "tikv-jemalloc-sys" = rec {
-        crateName = "tikv-jemalloc-sys";
-        version = "0.5.4+5.3.0-patched";
-        edition = "2018";
-        links = "jemalloc";
-        sha256 = "1lc5vm1p9dqdvd3mn3264zddnd7z6i95ch3y69prnjgxp0y480ll";
-        authors = [
-          "Alex Crichton <alex@alexcrichton.com>"
-          "Gonzalo Brito Gadeschi <gonzalobg88@gmail.com>"
-          "The TiKV Project Developers"
-        ];
-        dependencies = [
-          {
-            name = "libc";
-            packageId = "libc";
-            usesDefaultFeatures = false;
-          }
-        ];
-        buildDependencies = [
-          {
-            name = "cc";
-            packageId = "cc";
-          }
-        ];
-        features = {
-          "background_threads" = [ "background_threads_runtime_support" ];
-          "default" = [ "background_threads_runtime_support" ];
-        };
-        resolvedDefaultFeatures = [ "background_threads_runtime_support" ];
-      };
-      "tikv-jemallocator" = rec {
-        crateName = "tikv-jemallocator";
-        version = "0.5.4";
-        edition = "2018";
-        sha256 = "1jpanfm9az8hcbg6dyxdabykx03lj0j4g9cbwfa6rig5dg1f0pwn";
-        authors = [
-          "Alex Crichton <alex@alexcrichton.com>"
-          "Gonzalo Brito Gadeschi <gonzalobg88@gmail.com>"
-          "Simon Sapin <simon.sapin@exyr.org>"
-          "Steven Fackler <sfackler@gmail.com>"
-          "The TiKV Project Developers"
-        ];
-        dependencies = [
-          {
-            name = "libc";
-            packageId = "libc";
-            usesDefaultFeatures = false;
-          }
-          {
-            name = "tikv-jemalloc-sys";
-            packageId = "tikv-jemalloc-sys";
-            usesDefaultFeatures = false;
-          }
-        ];
-        features = {
-          "background_threads" = [ "tikv-jemalloc-sys/background_threads" ];
-          "background_threads_runtime_support" = [ "tikv-jemalloc-sys/background_threads_runtime_support" ];
-          "debug" = [ "tikv-jemalloc-sys/debug" ];
-          "default" = [ "background_threads_runtime_support" ];
-          "disable_initial_exec_tls" = [ "tikv-jemalloc-sys/disable_initial_exec_tls" ];
-          "profiling" = [ "tikv-jemalloc-sys/profiling" ];
-          "stats" = [ "tikv-jemalloc-sys/stats" ];
-          "unprefixed_malloc_on_supported_platforms" = [ "tikv-jemalloc-sys/unprefixed_malloc_on_supported_platforms" ];
-        };
-        resolvedDefaultFeatures = [ "background_threads_runtime_support" "default" ];
-      };
       "time" = rec {
         crateName = "time";
         version = "0.3.34";
@@ -15531,6 +15531,10 @@ rec {
             packageId = "itertools 0.12.0";
           }
           {
+            name = "mimalloc";
+            packageId = "mimalloc";
+          }
+          {
             name = "prost";
             packageId = "prost 0.13.1";
           }
@@ -15895,6 +15899,10 @@ rec {
             packageId = "dirs";
           }
           {
+            name = "mimalloc";
+            packageId = "mimalloc";
+          }
+          {
             name = "nix-compat";
             packageId = "nix-compat";
           }
@@ -15923,11 +15931,6 @@ rec {
             packageId = "thiserror";
           }
           {
-            name = "tikv-jemallocator";
-            packageId = "tikv-jemallocator";
-            target = { target, features }: (!("msvc" == target."env" or null));
-          }
-          {
             name = "tokio";
             packageId = "tokio";
           }
@@ -16121,6 +16124,10 @@ rec {
             packageId = "itertools 0.12.0";
           }
           {
+            name = "mimalloc";
+            packageId = "mimalloc";
+          }
+          {
             name = "pretty_assertions";
             packageId = "pretty_assertions";
           }
@@ -16132,11 +16139,6 @@ rec {
             name = "tempfile";
             packageId = "tempfile";
           }
-          {
-            name = "tikv-jemallocator";
-            packageId = "tikv-jemallocator";
-            target = { target, features }: (!("msvc" == target."env" or null));
-          }
         ];
         features = {
           "arbitrary" = [ "proptest" "test-strategy" "imbl/proptest" ];
@@ -16253,11 +16255,6 @@ rec {
             packageId = "thiserror";
           }
           {
-            name = "tikv-jemallocator";
-            packageId = "tikv-jemallocator";
-            target = { target, features }: (!("msvc" == target."env" or null));
-          }
-          {
             name = "tokio";
             packageId = "tokio";
           }
@@ -16328,6 +16325,10 @@ rec {
             packageId = "lazy_static";
           }
           {
+            name = "mimalloc";
+            packageId = "mimalloc";
+          }
+          {
             name = "nix";
             packageId = "nix 0.27.1";
             features = [ "fs" ];
@@ -16447,6 +16448,10 @@ rec {
             packageId = "lru";
           }
           {
+            name = "mimalloc";
+            packageId = "mimalloc";
+          }
+          {
             name = "nix-compat";
             packageId = "nix-compat";
             features = [ "async" ];
diff --git a/tvix/build/Cargo.toml b/tvix/build/Cargo.toml
index c0cf86408087..8bb68783f0ea 100644
--- a/tvix/build/Cargo.toml
+++ b/tvix/build/Cargo.toml
@@ -16,6 +16,7 @@ tvix-castore = { path = "../castore" }
 tvix-tracing = { path = "../tracing" }
 tracing = "0.1.40"
 url = "2.4.0"
+mimalloc = "0.1.43"
 
 [dependencies.tonic-reflection]
 optional = true
diff --git a/tvix/build/src/bin/tvix-build.rs b/tvix/build/src/bin/tvix-build.rs
index 7f077a88dd8f..93e85871caab 100644
--- a/tvix/build/src/bin/tvix-build.rs
+++ b/tvix/build/src/bin/tvix-build.rs
@@ -17,6 +17,11 @@ use tvix_build::proto::FILE_DESCRIPTOR_SET;
 #[cfg(feature = "tonic-reflection")]
 use tvix_castore::proto::FILE_DESCRIPTOR_SET as CASTORE_FILE_DESCRIPTOR_SET;
 
+use mimalloc::MiMalloc;
+
+#[global_allocator]
+static GLOBAL: MiMalloc = MiMalloc;
+
 #[derive(Parser)]
 #[command(author, version, about, long_about = None)]
 struct Cli {
diff --git a/tvix/cli/Cargo.toml b/tvix/cli/Cargo.toml
index 7f93da85d47a..2b624917ee87 100644
--- a/tvix/cli/Cargo.toml
+++ b/tvix/cli/Cargo.toml
@@ -27,6 +27,7 @@ tokio = "1.28.0"
 tracing = "0.1.40"
 tracing-indicatif = "0.3.6"
 rustc-hash = "2.0.0"
+mimalloc = "0.1.43"
 
 [dependencies.wu-manber]
 git = "https://github.com/tvlfyi/wu-manber.git"
@@ -34,9 +35,6 @@ git = "https://github.com/tvlfyi/wu-manber.git"
 [dev-dependencies]
 expect-test = "1.5.0"
 
-[target.'cfg(not(target_env = "msvc"))'.dependencies]
-tikv-jemallocator = "0.5"
-
 [features]
 default = []
 tracy = ["tvix-tracing/tracy"]
diff --git a/tvix/cli/src/main.rs b/tvix/cli/src/main.rs
index f927665aeb76..379dd915cbfb 100644
--- a/tvix/cli/src/main.rs
+++ b/tvix/cli/src/main.rs
@@ -1,4 +1,5 @@
 use clap::Parser;
+use mimalloc::MiMalloc;
 use std::rc::Rc;
 use std::{fs, path::PathBuf};
 use tvix_cli::args::Args;
@@ -7,12 +8,8 @@ use tvix_cli::{init_io_handle, interpret, AllowIncomplete};
 use tvix_eval::observer::DisassemblingObserver;
 use tvix_glue::tvix_store_io::TvixStoreIO;
 
-#[cfg(not(target_env = "msvc"))]
-use tikv_jemallocator::Jemalloc;
-
-#[cfg(not(target_env = "msvc"))]
 #[global_allocator]
-static GLOBAL: Jemalloc = Jemalloc;
+static GLOBAL: MiMalloc = MiMalloc;
 
 /// Interpret the given code snippet, but only run the Tvix compiler
 /// on it and return errors and warnings.
diff --git a/tvix/eval/Cargo.toml b/tvix/eval/Cargo.toml
index cd8d01cbb10a..9637165e8500 100644
--- a/tvix/eval/Cargo.toml
+++ b/tvix/eval/Cargo.toml
@@ -39,13 +39,11 @@ rustc-hash = "2.0.0"
 [dev-dependencies]
 criterion = "0.5"
 itertools = "0.12.0"
+mimalloc = "0.1.43"
 pretty_assertions = "1.2.1"
 rstest = "0.19.0"
 tempfile = "3.3.0"
 
-[target.'cfg(not(target_env = "msvc"))'.dev-dependencies]
-tikv-jemallocator = "0.5"
-
 [features]
 default = ["impure", "arbitrary", "nix_tests"]
 
diff --git a/tvix/eval/benches/eval.rs b/tvix/eval/benches/eval.rs
index 36ca310f4465..f4d6489f1e5c 100644
--- a/tvix/eval/benches/eval.rs
+++ b/tvix/eval/benches/eval.rs
@@ -1,11 +1,9 @@
 use criterion::{black_box, criterion_group, criterion_main, Criterion};
 use itertools::Itertools;
-#[cfg(not(target_env = "msvc"))]
-use tikv_jemallocator::Jemalloc;
+use mimalloc::MiMalloc;
 
-#[cfg(not(target_env = "msvc"))]
 #[global_allocator]
-static GLOBAL: Jemalloc = Jemalloc;
+static GLOBAL: MiMalloc = MiMalloc;
 
 fn interpret(code: &str) {
     tvix_eval::Evaluation::builder_pure()
diff --git a/tvix/glue/Cargo.toml b/tvix/glue/Cargo.toml
index 4c72ed676bc6..6e9f313aa0a9 100644
--- a/tvix/glue/Cargo.toml
+++ b/tvix/glue/Cargo.toml
@@ -36,13 +36,11 @@ clap = { version = "4.4.0", default-features = false }
 [dependencies.wu-manber]
 git = "https://github.com/tvlfyi/wu-manber.git"
 
-[target.'cfg(not(target_env = "msvc"))'.dependencies]
-tikv-jemallocator = "0.5"
-
 [dev-dependencies]
 criterion = { version = "0.5", features = ["html_reports"] }
 hex-literal = "0.4.1"
 lazy_static = "1.4.0"
+mimalloc = "0.1.43"
 nix = { version = "0.27.1", features = [ "fs" ] }
 pretty_assertions = "1.4.0"
 rstest = "0.19.0"
diff --git a/tvix/glue/benches/eval.rs b/tvix/glue/benches/eval.rs
index 8958d9448573..0a27d9aa26fe 100644
--- a/tvix/glue/benches/eval.rs
+++ b/tvix/glue/benches/eval.rs
@@ -1,9 +1,8 @@
 use clap::Parser;
 use criterion::{black_box, criterion_group, criterion_main, Criterion};
 use lazy_static::lazy_static;
+use mimalloc::MiMalloc;
 use std::{env, rc::Rc, sync::Arc, time::Duration};
-#[cfg(not(target_env = "msvc"))]
-use tikv_jemallocator::Jemalloc;
 use tvix_build::buildservice::DummyBuildService;
 use tvix_eval::{builtins::impure_builtins, EvalIO};
 use tvix_glue::{
@@ -14,9 +13,8 @@ use tvix_glue::{
 };
 use tvix_store::utils::{construct_services, ServiceUrlsMemory};
 
-#[cfg(not(target_env = "msvc"))]
 #[global_allocator]
-static GLOBAL: Jemalloc = Jemalloc;
+static GLOBAL: MiMalloc = MiMalloc;
 
 lazy_static! {
     static ref TOKIO_RUNTIME: tokio::runtime::Runtime = tokio::runtime::Runtime::new().unwrap();
diff --git a/tvix/nar-bridge/Cargo.toml b/tvix/nar-bridge/Cargo.toml
index c2a03d981793..ba5f21ee6021 100644
--- a/tvix/nar-bridge/Cargo.toml
+++ b/tvix/nar-bridge/Cargo.toml
@@ -28,6 +28,7 @@ url = "2.4.0"
 serde = { version = "1.0.204", features = ["derive"] }
 lru = "0.12.3"
 parking_lot = "0.12.3"
+mimalloc = "0.1.43"
 
 [build-dependencies]
 prost-build = "0.13.1"
diff --git a/tvix/nar-bridge/src/bin/nar-bridge.rs b/tvix/nar-bridge/src/bin/nar-bridge.rs
index cf312649d147..48eba0ac44ac 100644
--- a/tvix/nar-bridge/src/bin/nar-bridge.rs
+++ b/tvix/nar-bridge/src/bin/nar-bridge.rs
@@ -1,10 +1,14 @@
 use clap::Parser;
+use mimalloc::MiMalloc;
 use nar_bridge::AppState;
 use tower::ServiceBuilder;
 use tower_http::trace::{DefaultMakeSpan, TraceLayer};
 use tracing::info;
 use tvix_store::utils::ServiceUrlsGrpc;
 
+#[global_allocator]
+static GLOBAL: MiMalloc = MiMalloc;
+
 /// Expose the Nix HTTP Binary Cache protocol for a tvix-store.
 #[derive(Parser)]
 #[command(author, version, about, long_about = None)]
diff --git a/tvix/nix-compat/Cargo.toml b/tvix/nix-compat/Cargo.toml
index 73928b1acd30..dc77c5cf0ad1 100644
--- a/tvix/nix-compat/Cargo.toml
+++ b/tvix/nix-compat/Cargo.toml
@@ -20,6 +20,7 @@ ed25519 = "2.2.3"
 ed25519-dalek = "2.1.0"
 enum-primitive-derive = "0.3.0"
 glob = "0.3.0"
+mimalloc = "0.1.43"
 nom = "7.1.3"
 num-traits = "0.2.18"
 serde = { version = "1.0", features = ["derive"] }
@@ -41,6 +42,7 @@ criterion = { version = "0.5", features = ["html_reports"] }
 futures = { version = "0.3.30", default-features = false, features = ["executor"] }
 hex-literal = "0.4.1"
 lazy_static = "1.4.0"
+mimalloc = "0.1.43"
 pretty_assertions = "1.4.0"
 rstest = "0.19.0"
 serde_json = "1.0"
diff --git a/tvix/nix-compat/benches/derivation_parse_aterm.rs b/tvix/nix-compat/benches/derivation_parse_aterm.rs
index 4ace7d4480f4..6557dd17af37 100644
--- a/tvix/nix-compat/benches/derivation_parse_aterm.rs
+++ b/tvix/nix-compat/benches/derivation_parse_aterm.rs
@@ -1,8 +1,12 @@
 use std::path::Path;
 
 use criterion::{black_box, criterion_group, criterion_main, Criterion};
+use mimalloc::MiMalloc;
 use nix_compat::derivation::Derivation;
 
+#[global_allocator]
+static GLOBAL: MiMalloc = MiMalloc;
+
 const RESOURCES_PATHS: &str = "src/derivation/tests/derivation_tests/ok";
 
 fn bench_aterm_parser(c: &mut Criterion) {
diff --git a/tvix/nix-compat/benches/narinfo_parse.rs b/tvix/nix-compat/benches/narinfo_parse.rs
index 7ffd24d12bc3..f35ba8468a88 100644
--- a/tvix/nix-compat/benches/narinfo_parse.rs
+++ b/tvix/nix-compat/benches/narinfo_parse.rs
@@ -1,8 +1,12 @@
 use criterion::{black_box, criterion_group, criterion_main, Criterion, Throughput};
 use lazy_static::lazy_static;
+use mimalloc::MiMalloc;
 use nix_compat::narinfo::NarInfo;
 use std::{io, str};
 
+#[global_allocator]
+static GLOBAL: MiMalloc = MiMalloc;
+
 const SAMPLE: &str = r#"StorePath: /nix/store/1pajsq519irjy86vli20bgq1wr1q3pny-banking-0.3.0
 URL: nar/0rdn027rxqbl42bv9jxhsipgq2hwqdapvwmdzligmzdmz2p9vybs.nar.xz
 Compression: xz
diff --git a/tvix/nix-compat/src/bin/drvfmt.rs b/tvix/nix-compat/src/bin/drvfmt.rs
index ddc1f0389f26..fca22c2cb2ae 100644
--- a/tvix/nix-compat/src/bin/drvfmt.rs
+++ b/tvix/nix-compat/src/bin/drvfmt.rs
@@ -3,6 +3,11 @@ use std::{collections::BTreeMap, io::Read};
 use nix_compat::derivation::Derivation;
 use serde_json::json;
 
+use mimalloc::MiMalloc;
+
+#[global_allocator]
+static GLOBAL: MiMalloc = MiMalloc;
+
 /// construct a serde_json::Value from a Derivation.
 /// Some environment values can be non-valid UTF-8 strings.
 /// `serde_json` prints them out really unreadable.
diff --git a/tvix/store/Cargo.toml b/tvix/store/Cargo.toml
index de7d0a5042d0..0cbaa102f051 100644
--- a/tvix/store/Cargo.toml
+++ b/tvix/store/Cargo.toml
@@ -46,6 +46,7 @@ hyper-util = "0.1.6"
 toml = { version = "0.8.15", optional = true }
 tonic-health = { version = "0.12.1", default-features = false }
 redb = "2.1.1"
+mimalloc = "0.1.43"
 
 [dependencies.tonic-reflection]
 optional = true
diff --git a/tvix/store/src/bin/tvix-store.rs b/tvix/store/src/bin/tvix-store.rs
index 37e1672c79df..d639a6e9d78d 100644
--- a/tvix/store/src/bin/tvix-store.rs
+++ b/tvix/store/src/bin/tvix-store.rs
@@ -42,6 +42,11 @@ use tvix_castore::proto::FILE_DESCRIPTOR_SET as CASTORE_FILE_DESCRIPTOR_SET;
 #[cfg(feature = "tonic-reflection")]
 use tvix_store::proto::FILE_DESCRIPTOR_SET;
 
+use mimalloc::MiMalloc;
+
+#[global_allocator]
+static GLOBAL: MiMalloc = MiMalloc;
+
 #[derive(Parser)]
 #[command(author, version, about, long_about = None)]
 struct Cli {