From e3559411523a7ffa427a247c5d09623ed79833d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Fri, 1 Oct 2021 10:20:09 +0200 Subject: [PATCH 1/3] Remove incorrect proof about Jemalloc The truth is that Jemalloc is not always the default allocator. This is only true for the polkadot binary. --- node/overseer/src/lib.rs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/node/overseer/src/lib.rs b/node/overseer/src/lib.rs index 331bf6378dda..44087a667ef7 100644 --- a/node/overseer/src/lib.rs +++ b/node/overseer/src/lib.rs @@ -518,18 +518,26 @@ where } let subsystem_meters = overseer.map_subsystems(ExtractNameAndMeters); - let memory_stats = - MemoryAllocationTracker::new().expect("Jemalloc is the default allocator. qed"); - - let metronome = Metronome::new(std::time::Duration::from_millis(950)).for_each(move |_| { - match memory_stats.snapshot() { + let collect_memory_stats: Box = match MemoryAllocationTracker::new() { + Ok(memory_stats) => Box::new(move |metrics: &OverseerMetrics| match memory_stats.snapshot() { Ok(memory_stats_snapshot) => { tracing::trace!(target: LOG_TARGET, "memory_stats: {:?}", &memory_stats_snapshot); - metronome_metrics.memory_stats_snapshot(memory_stats_snapshot); + metrics.memory_stats_snapshot(memory_stats_snapshot); }, - Err(e) => tracing::debug!(target: LOG_TARGET, "Failed to obtain memory stats: {:?}", e), - } + }), + Err(_) => { + tracing::debug!( + target: LOG_TARGET, + "Jemalloc not set as allocator, so memory allocations will not be tracked", + ); + + Box::new(|_| {}) + }, + }; + + let metronome = Metronome::new(std::time::Duration::from_millis(950)).for_each(move |_| { + collect_memory_stats(&metronome_metrics); // We combine the amount of messages from subsystems to the overseer // as well as the amount of messages from external sources to the overseer From c9c9655417efc50095b246390334bbd70018ee20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Fri, 1 Oct 2021 11:09:50 +0200 Subject: [PATCH 2/3] Fmt --- node/overseer/src/lib.rs | 42 +++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/node/overseer/src/lib.rs b/node/overseer/src/lib.rs index 44087a667ef7..510b6cba0189 100644 --- a/node/overseer/src/lib.rs +++ b/node/overseer/src/lib.rs @@ -518,23 +518,33 @@ where } let subsystem_meters = overseer.map_subsystems(ExtractNameAndMeters); - let collect_memory_stats: Box = match MemoryAllocationTracker::new() { - Ok(memory_stats) => Box::new(move |metrics: &OverseerMetrics| match memory_stats.snapshot() { - Ok(memory_stats_snapshot) => { - tracing::trace!(target: LOG_TARGET, "memory_stats: {:?}", &memory_stats_snapshot); - metrics.memory_stats_snapshot(memory_stats_snapshot); + let collect_memory_stats: Box = + match MemoryAllocationTracker::new() { + Ok(memory_stats) => + Box::new(move |metrics: &OverseerMetrics| match memory_stats.snapshot() { + Ok(memory_stats_snapshot) => { + tracing::trace!( + target: LOG_TARGET, + "memory_stats: {:?}", + &memory_stats_snapshot + ); + metrics.memory_stats_snapshot(memory_stats_snapshot); + }, + Err(e) => tracing::debug!( + target: LOG_TARGET, + "Failed to obtain memory stats: {:?}", + e + ), + }), + Err(_) => { + tracing::debug!( + target: LOG_TARGET, + "Jemalloc not set as allocator, so memory allocations will not be tracked", + ); + + Box::new(|_| {}) }, - Err(e) => tracing::debug!(target: LOG_TARGET, "Failed to obtain memory stats: {:?}", e), - }), - Err(_) => { - tracing::debug!( - target: LOG_TARGET, - "Jemalloc not set as allocator, so memory allocations will not be tracked", - ); - - Box::new(|_| {}) - }, - }; + }; let metronome = Metronome::new(std::time::Duration::from_millis(950)).for_each(move |_| { collect_memory_stats(&metronome_metrics); From f0221d22f193b641bb11d6ce4fdd3931951623f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Fri, 1 Oct 2021 11:22:06 +0200 Subject: [PATCH 3/3] Rephrase --- node/overseer/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/overseer/src/lib.rs b/node/overseer/src/lib.rs index 510b6cba0189..961e1e659f42 100644 --- a/node/overseer/src/lib.rs +++ b/node/overseer/src/lib.rs @@ -539,7 +539,7 @@ where Err(_) => { tracing::debug!( target: LOG_TARGET, - "Jemalloc not set as allocator, so memory allocations will not be tracked", + "Memory allocation tracking is not supported by the allocator.", ); Box::new(|_| {})