Skip to content

Commit

Permalink
fix(core): don't show warning about max allocation groups if tracing …
Browse files Browse the repository at this point in the history
…not enabled (#18589)
  • Loading branch information
tobz authored Sep 18, 2023
1 parent 0e60001 commit 3afda3c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/internal_telemetry/allocations/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -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
}
6 changes: 3 additions & 3 deletions src/topology/running.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down

0 comments on commit 3afda3c

Please sign in to comment.