build releases with mimalloc

This commit is contained in:
Scott Lamb
2025-04-03 09:16:04 -07:00
parent 0ccc6d0769
commit 39b6f6c49c
10 changed files with 79 additions and 18 deletions

View File

@@ -9,6 +9,7 @@ publish = false
rust-version = "1.82"
[features]
mimalloc = ["dep:libmimalloc-sys"]
nightly = []
[lib]
@@ -16,10 +17,14 @@ path = "lib.rs"
[dependencies]
ahash = "0.8"
coded = { git = "https://github.com/scottlamb/coded", rev = "2c97994974a73243d5dd12134831814f42cdb0e8"}
coded = { git = "https://github.com/scottlamb/coded", rev = "2c97994974a73243d5dd12134831814f42cdb0e8" }
futures = "0.3"
jiff = { workspace = true }
libc = "0.2"
libmimalloc-sys = { version = "0.1.41", features = [
"override",
"extended",
], optional = true }
nix = { workspace = true, features = ["time"] }
nom = "7.0.0"
rusqlite = { workspace = true }

View File

@@ -75,3 +75,16 @@ impl std::ops::Deref for Condvar {
&self.0
}
}
pub fn ensure_malloc_used() {
#[cfg(feature = "mimalloc")]
{
// This is a load-bearing debug line.
// Building `libmimalloc-sys` with the `override` feature will override `malloc` and
// `free` as used through the Rust global allocator, SQLite, and `libc`. But...`cargo`
// doesn't seem to build `libmimalloc-sys` at all if it's not referenced from Rust code.
tracing::debug!("mimalloc version {}", unsafe {
libmimalloc_sys::mi_version()
})
}
}