diff --git a/Cargo.toml b/Cargo.toml index b583f5a..e499b23 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,9 @@ version = "0.1.0" [lib] crate-type = ["cdylib"] +[target.'cfg(unix)'.dependencies] +tikv-jemallocator = { version = "0.6", features = ["disable_initial_exec_tls"] } + [dependencies] bitcoin-payment-instructions = { version = "0.5.0", default-features = false, features = [ "http", diff --git a/src/lib.rs b/src/lib.rs index be6d4b1..d5b6505 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,12 @@ #![deny(clippy::all)] +/// Use jemalloc to reduce memory fragmentation during channel monitor +/// deserialization and node boot. glibc malloc fragments heavily with +/// Rust's alloc patterns (not available on Windows). +#[cfg(unix)] +#[global_allocator] +static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; + use std::{ collections::{HashMap, HashSet}, convert::TryFrom,