From ad140fbca2236c4c66b8adbbbcb8f622564b6709 Mon Sep 17 00:00:00 2001 From: behzad nouri Date: Fri, 24 Sep 2021 14:26:25 +0000 Subject: [PATCH 1/2] 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 --- Cargo.lock | 34 ++++++++++++++++++++++++++++++++++ validator/Cargo.toml | 3 +++ validator/src/main.rs | 7 +++++++ 3 files changed, 44 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 258f361af1b8cc..bb290d43265a90 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5636,6 +5636,7 @@ dependencies = [ "solana-version", "solana-vote-program", "symlink", + "tikv-jemallocator", ] [[package]] @@ -6035,6 +6036,39 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bcbb6aa301e5d3b0b5ef639c9a9c7e2f1c944f177b460c04dc24c69b1fa2bd99" [[package]] +<<<<<<< HEAD +======= +name = "thread_local" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8018d24e04c95ac8790716a5987d0fec4f8b27249ffa0f7d33f1369bdfb88cbd" +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]] +>>>>>>> 2cf081d86 (uses tikv_jemallocator::Jemalloc as the global allocator (#20149)) name = "time" version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/validator/Cargo.toml b/validator/Cargo.toml index 41559764476a63..43054ff23d5e64 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 2fae79a1e184fa..71edf989002bfe 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, From 38ae37a0cef7fe8d51d922d11ddec4e3a626a2df Mon Sep 17 00:00:00 2001 From: behzad nouri Date: Fri, 24 Sep 2021 11:16:07 -0400 Subject: [PATCH 2/2] removes backport merge conflicts --- Cargo.lock | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bb290d43265a90..8e758424d1a439 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6035,17 +6035,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bcbb6aa301e5d3b0b5ef639c9a9c7e2f1c944f177b460c04dc24c69b1fa2bd99" -[[package]] -<<<<<<< HEAD -======= -name = "thread_local" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8018d24e04c95ac8790716a5987d0fec4f8b27249ffa0f7d33f1369bdfb88cbd" -dependencies = [ - "once_cell", -] - [[package]] name = "tikv-jemalloc-sys" version = "0.4.2+5.2.1-patched.2" @@ -6068,7 +6057,6 @@ dependencies = [ ] [[package]] ->>>>>>> 2cf081d86 (uses tikv_jemallocator::Jemalloc as the global allocator (#20149)) name = "time" version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index"