From ff27e95cb0629e58cdb14415510ce33005061780 Mon Sep 17 00:00:00 2001 From: Kevin Longe <273747162+kvlonge@users.noreply.github.com> Date: Mon, 9 Nov 2026 12:48:05 +0000 Subject: [PATCH] perf: stop mimalloc asking for transparent huge pages mimalloc madvises its 1 GiB arenas for transparent huge pages, so on Linux hosts with THP in madvise mode (the Ubuntu default) every partly used 2 MiB page stayed resident in full. A cold 10,000-model compile held about 470 MiB of huge pages at its peak. Building mimalloc with no_thp keeps those arenas on normal pages and lowers that compile's peak memory by about 85 MB, with unchanged wall and CPU time. Other platforms are unaffected. --- Cargo.toml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 3f05fa9a2..a2451c352 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -81,7 +81,9 @@ globset = "0.4" junction = { version = "2.1.0", default-features = false } keyring = { version = "3.6.3", default-features = false } # Python loads the extension with dlopen, so mimalloc must not use initial-exec TLS. -mimalloc = { version = "0.1", default-features = false, features = ["local_dynamic_tls"] } +# no_thp: mimalloc otherwise asks for transparent huge pages on its 1 GiB arenas, and each +# partly used 2 MiB page then stays resident in full, which raises peak memory. +mimalloc = { version = "0.1", default-features = false, features = ["local_dynamic_tls", "no_thp"] } proc-macro2 = { version = "1", features = ["span-locations"] } pyo3 = { version = "0.26", features = ["abi3-py312"] } rpassword = "7.5.4"