From 1dcfec5dea41669237224a70d967bdc70795d4a9 Mon Sep 17 00:00:00 2001 From: behzad nouri Date: Thu, 23 Sep 2021 17:28:55 -0400 Subject: [PATCH] uses tikv_jemallocator::Jemalloc as the global allocator https://github.com/solana-labs/solana/pull/16346 switched default allocator from jemalloc to system allocator, but that has shown regressions in form of higher ram usage causing nodes go OOM. This commit sets jemalloc as the default allocator. --- Cargo.lock | 22 ++++++++++++++++++++++ validator/Cargo.toml | 3 +++ validator/src/main.rs | 7 +++++++ 3 files changed, 32 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index bf856052d47222..3c7d60431c77d1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5723,6 +5723,7 @@ dependencies = [ "solana-version", "solana-vote-program", "symlink", + "tikv-jemallocator", ] [[package]] @@ -6138,6 +6139,27 @@ dependencies = [ "once_cell", ] +[[package]] +name = "tikv-jemalloc-sys" +version = "0.4.2+5.2.1-patched.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5844e429d797c62945a566f8da4e24c7fe3fbd5d6617fd8bf7a0b7dc1ee0f22e" +dependencies = [ + "cc", + "fs_extra", + "libc", +] + +[[package]] +name = "tikv-jemallocator" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c14a5a604eb8715bc5785018a37d00739b180bcf609916ddf4393d33d49ccdf" +dependencies = [ + "libc", + "tikv-jemalloc-sys", +] + [[package]] name = "time" version = "0.1.43" diff --git a/validator/Cargo.toml b/validator/Cargo.toml index 3fcd7b76d9f7a1..d5867ddd8b3bb5 100644 --- a/validator/Cargo.toml +++ b/validator/Cargo.toml @@ -49,6 +49,9 @@ solana-version = { path = "../version", version = "=1.8.0" } solana-vote-program = { path = "../programs/vote", version = "=1.8.0" } symlink = "0.1.0" +[target.'cfg(not(target_env = "msvc"))'.dependencies] +jemallocator = {package = "tikv-jemallocator", version = "0.4.1"} + [target."cfg(unix)".dependencies] libc = "0.2.102" signal-hook = "0.2.3" diff --git a/validator/src/main.rs b/validator/src/main.rs index 92f1ef55e8ce7b..066bc9e97fc3e3 100644 --- a/validator/src/main.rs +++ b/validator/src/main.rs @@ -86,6 +86,13 @@ use { }, }; +#[cfg(not(target_env = "msvc"))] +use jemallocator::Jemalloc; + +#[cfg(not(target_env = "msvc"))] +#[global_allocator] +static GLOBAL: Jemalloc = Jemalloc; + #[derive(Debug, PartialEq)] enum Operation { Initialize,