Skip to content

Commit 4a3e248

Browse files
Add heaptrack support (#7764)
Although we're working on jemalloc profiler support in #7746, heaptrack seems to be producing more sensible results. This PR adds a heaptrack profile and a heaptrack feature so that we no longer need to patch the code in order to use heaptrack. This may prove complementary to jemalloc profiling, so I think there is no harm in having both.
1 parent 1046dfb commit 4a3e248

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,5 +289,9 @@ panic = "abort"
289289
codegen-units = 1
290290
overflow-checks = true
291291

292+
[profile.release-debug]
293+
inherits = "release"
294+
debug = true
295+
292296
[patch.crates-io]
293297
quick-protobuf = { git = "https://github.com/sigp/quick-protobuf.git", rev = "681f413312404ab6e51f0b46f39b0075c6f4ebfd" }

lighthouse/Cargo.toml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ beacon-node-leveldb = ["store/leveldb"]
3535
beacon-node-redb = ["store/redb"]
3636
# Supports console subscriber for debugging
3737
console-subscriber = ["console-subscriber/default"]
38+
# Turns off jemalloc so that heaptrack may be used to analyse memory usage.
39+
heaptrack = []
3840

39-
# Deprecated. This is now enabled by default on non windows targets.
41+
# Deprecated. This is now enabled by default on non windows targets (unless heaptrack is enabled).
4042
jemalloc = []
4143

4244
[dependencies]
@@ -71,12 +73,12 @@ unused_port = { workspace = true }
7173
validator_client = { workspace = true }
7274
validator_manager = { path = "../validator_manager" }
7375

74-
[target.'cfg(not(target_os = "windows"))'.dependencies]
75-
malloc_utils = { workspace = true, features = ["jemalloc"] }
76-
77-
[target.'cfg(target_os = "windows")'.dependencies]
76+
[target.'cfg(any(target_os = "windows", features = "heaptrack"))'.dependencies]
7877
malloc_utils = { workspace = true }
7978

79+
[target.'cfg(not(any(target_os = "windows", features = "heaptrack")))'.dependencies]
80+
malloc_utils = { workspace = true, features = ["jemalloc"] }
81+
8082
[dev-dependencies]
8183
beacon_node_fallback = { workspace = true }
8284
beacon_processor = { workspace = true }

lighthouse/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ fn bls_hardware_acceleration() -> bool {
7474
}
7575

7676
fn allocator_name() -> String {
77-
#[cfg(target_os = "windows")]
77+
#[cfg(any(feature = "heaptrack", target_os = "windows"))]
7878
{
7979
"system".to_string()
8080
}
81-
#[cfg(not(target_os = "windows"))]
81+
#[cfg(not(any(feature = "heaptrack", target_os = "windows")))]
8282
match malloc_utils::jemalloc::page_size() {
8383
Ok(page_size) => format!("jemalloc ({}K)", page_size / 1024),
8484
Err(e) => format!("jemalloc (error: {e:?})"),

0 commit comments

Comments
 (0)