From 7ff33781e37e64d8a69d892304c65f3aeb04c2f4 Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Mon, 21 Jul 2025 11:00:24 +1000 Subject: [PATCH 1/3] Heaptrack --- Cargo.toml | 4 ++++ lighthouse/Cargo.toml | 8 +++++--- lighthouse/src/main.rs | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 817c2f2d802..061d2eb7937 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -289,5 +289,9 @@ panic = "abort" codegen-units = 1 overflow-checks = true +[profile.heaptrack] +inherits = "release" +debug = true + [patch.crates-io] quick-protobuf = { git = "https://github.com/sigp/quick-protobuf.git", rev = "681f413312404ab6e51f0b46f39b0075c6f4ebfd" } diff --git a/lighthouse/Cargo.toml b/lighthouse/Cargo.toml index 6a8fa00c1e0..7e735bf4c65 100644 --- a/lighthouse/Cargo.toml +++ b/lighthouse/Cargo.toml @@ -35,8 +35,10 @@ beacon-node-leveldb = ["store/leveldb"] beacon-node-redb = ["store/redb"] # Supports console subscriber for debugging console-subscriber = ["console-subscriber/default"] +# Turns off jemalloc so that heaptrack may be used to analyse memory usage. +heaptrack = [] -# Deprecated. This is now enabled by default on non windows targets. +# Deprecated. This is now enabled by default on non windows targets (unless heaptrack is enabled). jemalloc = [] [dependencies] @@ -71,10 +73,10 @@ unused_port = { workspace = true } validator_client = { workspace = true } validator_manager = { path = "../validator_manager" } -[target.'cfg(not(target_os = "windows"))'.dependencies] +[target.'cfg(not(any(target_os = "windows", features = "heaptrack")))'.dependencies] malloc_utils = { workspace = true, features = ["jemalloc"] } -[target.'cfg(target_os = "windows")'.dependencies] +[target.'cfg(any(target_os = "windows", features = "heaptrack"))'.dependencies] malloc_utils = { workspace = true } [dev-dependencies] diff --git a/lighthouse/src/main.rs b/lighthouse/src/main.rs index 10168d026fd..28b8c7b8fc4 100644 --- a/lighthouse/src/main.rs +++ b/lighthouse/src/main.rs @@ -74,11 +74,11 @@ fn bls_hardware_acceleration() -> bool { } fn allocator_name() -> String { - #[cfg(target_os = "windows")] + #[cfg(any(feature = "heaptrack", target_os = "windows"))] { "system".to_string() } - #[cfg(not(target_os = "windows"))] + #[cfg(not(any(feature = "heaptrack", target_os = "windows")))] match malloc_utils::jemalloc::page_size() { Ok(page_size) => format!("jemalloc ({}K)", page_size / 1024), Err(e) => format!("jemalloc (error: {e:?})"), From 1e207b12f0a55461aea16696295ed2374ba86841 Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Mon, 21 Jul 2025 11:26:05 +1000 Subject: [PATCH 2/3] Rename profile to release-debug --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 061d2eb7937..6737ff22c5e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -289,7 +289,7 @@ panic = "abort" codegen-units = 1 overflow-checks = true -[profile.heaptrack] +[profile.release-debug] inherits = "release" debug = true From dd009fbb4f848ce9de8f7a3c055699e42c0ca7fe Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Mon, 21 Jul 2025 11:32:38 +1000 Subject: [PATCH 3/3] Fix cargo sort --- lighthouse/Cargo.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lighthouse/Cargo.toml b/lighthouse/Cargo.toml index 7e735bf4c65..a6549f55744 100644 --- a/lighthouse/Cargo.toml +++ b/lighthouse/Cargo.toml @@ -73,12 +73,12 @@ unused_port = { workspace = true } validator_client = { workspace = true } validator_manager = { path = "../validator_manager" } -[target.'cfg(not(any(target_os = "windows", features = "heaptrack")))'.dependencies] -malloc_utils = { workspace = true, features = ["jemalloc"] } - [target.'cfg(any(target_os = "windows", features = "heaptrack"))'.dependencies] malloc_utils = { workspace = true } +[target.'cfg(not(any(target_os = "windows", features = "heaptrack")))'.dependencies] +malloc_utils = { workspace = true, features = ["jemalloc"] } + [dev-dependencies] beacon_node_fallback = { workspace = true } beacon_processor = { workspace = true }