From 085f5f945d3b177ba66eb7c2805beb39ca1c688e Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 24 Sep 2021 17:37:57 +0000 Subject: [PATCH] uses tikv_jemallocator::Jemalloc as the global allocator (backport #20149) (#20166) * uses tikv_jemallocator::Jemalloc as the global allocator (#20149) 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: https://discord.com/channels/428295358100013066/439194979856809985/890413193858539580 This commit sets jemalloc as the default allocator. (cherry picked from commit 2cf081d86333d83a1364196f811de30b825a7b42) # Conflicts: # Cargo.lock * removes backport merge conflicts Co-authored-by: behzad nouri --- 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 fdbda427d1..7c20f50bf4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5637,6 +5637,7 @@ dependencies = [ "solana-version", "solana-vote-program", "symlink", + "tikv-jemallocator", ] [[package]] @@ -6035,6 +6036,27 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bcbb6aa301e5d3b0b5ef639c9a9c7e2f1c944f177b460c04dc24c69b1fa2bd99" +[[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 4155976447..43054ff23d 100644 --- a/validator/Cargo.toml +++ b/validator/Cargo.toml @@ -50,6 +50,9 @@ solana-version = { path = "../version", version = "=1.7.13" } solana-vote-program = { path = "../programs/vote", version = "=1.7.13" } 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.81" signal-hook = "0.1.15" diff --git a/validator/src/main.rs b/validator/src/main.rs index 2fae79a1e1..71edf98900 100644 --- a/validator/src/main.rs +++ b/validator/src/main.rs @@ -78,6 +78,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,