From 3afda3c5e8fca52dc689acb4d283988dd304c2fd Mon Sep 17 00:00:00 2001 From: Toby Lawrence Date: Mon, 18 Sep 2023 11:25:10 -0400 Subject: [PATCH] fix(core): don't show warning about max allocation groups if tracing not enabled (#18589) --- src/internal_telemetry/allocations/mod.rs | 7 ++++++- src/topology/running.rs | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/internal_telemetry/allocations/mod.rs b/src/internal_telemetry/allocations/mod.rs index 6cbd433b00b62..b34c40d136d0c 100644 --- a/src/internal_telemetry/allocations/mod.rs +++ b/src/internal_telemetry/allocations/mod.rs @@ -21,12 +21,17 @@ pub(crate) use self::allocator::{ }; const NUM_GROUPS: usize = 128; + // Allocations are not tracked during startup. // We use the Relaxed ordering for both stores and loads of this atomic as no other threads exist when // this code is running, and all future threads will have a happens-after relationship with // this thread -- the main thread -- ensuring that they see the latest value of TRACK_ALLOCATIONS. pub static TRACK_ALLOCATIONS: AtomicBool = AtomicBool::new(false); +pub fn is_allocation_tracing_enabled() -> bool { + TRACK_ALLOCATIONS.load(Ordering::Acquire) +} + /// Track allocations and deallocations separately. struct GroupMemStatsStorage { allocations: [AtomicU64; NUM_GROUPS], @@ -207,6 +212,6 @@ pub fn acquire_allocation_group_id( // TODO: Technically, `NUM_GROUPS` is lower (128) than the upper bound for the // `AllocationGroupId::register` call itself (253), so we can hardcode `NUM_GROUPS` here knowing // it's the lower of the two values and will trigger first.. but this may not always be true. - info!("Maximum number of registrable allocation group IDs reached ({}). Allocations for component '{}' will be attributed to the root allocation group.", NUM_GROUPS, component_id); + warn!("Maximum number of registrable allocation group IDs reached ({}). Allocations for component '{}' will be attributed to the root allocation group.", NUM_GROUPS, component_id); AllocationGroupId::ROOT } diff --git a/src/topology/running.rs b/src/topology/running.rs index 78cf93bab28d4..bb300dd7e5652 100644 --- a/src/topology/running.rs +++ b/src/topology/running.rs @@ -839,7 +839,7 @@ impl RunningTopology { let task_span = span.or_current(); #[cfg(feature = "allocation-tracing")] - { + if crate::internal_telemetry::allocations::is_allocation_tracing_enabled() { let group_id = crate::internal_telemetry::allocations::acquire_allocation_group_id( task.id().to_string(), "sink".to_string(), @@ -882,7 +882,7 @@ impl RunningTopology { let task_span = span.or_current(); #[cfg(feature = "allocation-tracing")] - { + if crate::internal_telemetry::allocations::is_allocation_tracing_enabled() { let group_id = crate::internal_telemetry::allocations::acquire_allocation_group_id( task.id().to_string(), "transform".to_string(), @@ -925,7 +925,7 @@ impl RunningTopology { let task_span = span.or_current(); #[cfg(feature = "allocation-tracing")] - { + if crate::internal_telemetry::allocations::is_allocation_tracing_enabled() { let group_id = crate::internal_telemetry::allocations::acquire_allocation_group_id( task.id().to_string(), "source".to_string(),