From 48f115dbcecd16f5e8862dba3d24fda979a1da94 Mon Sep 17 00:00:00 2001 From: Stepan Koltsov Date: Mon, 1 Jan 2024 14:28:56 +0000 Subject: [PATCH] Fix spans for system --- crates/bevy_ecs/src/system/commands/mod.rs | 4 +++- .../src/system/commands/parallel_scope.rs | 4 +++- .../src/system/exclusive_function_system.rs | 4 +++- crates/bevy_ecs/src/system/function_system.rs | 15 +++------------ 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/crates/bevy_ecs/src/system/commands/mod.rs b/crates/bevy_ecs/src/system/commands/mod.rs index 80de73f9f15ab..405327f79b2ac 100644 --- a/crates/bevy_ecs/src/system/commands/mod.rs +++ b/crates/bevy_ecs/src/system/commands/mod.rs @@ -9,6 +9,8 @@ use crate::{ world::{EntityWorldMut, FromWorld, World}, }; use bevy_ecs_macros::SystemParam; +#[cfg(feature = "trace")] +use bevy_utils::tracing::info_span; use bevy_utils::tracing::{error, info}; pub use command_queue::CommandQueue; pub use parallel_scope::*; @@ -119,7 +121,7 @@ impl SystemBuffer for CommandQueue { #[inline] fn apply(&mut self, _system_meta: &SystemMeta, world: &mut World) { #[cfg(feature = "trace")] - let _span_guard = _system_meta.commands_span.enter(); + let _span_guard = info_span!("system_commands", name = _system_meta.name()).entered(); self.apply(world); } } diff --git a/crates/bevy_ecs/src/system/commands/parallel_scope.rs b/crates/bevy_ecs/src/system/commands/parallel_scope.rs index 6296f0293393c..d6402f2dbee63 100644 --- a/crates/bevy_ecs/src/system/commands/parallel_scope.rs +++ b/crates/bevy_ecs/src/system/commands/parallel_scope.rs @@ -1,5 +1,7 @@ use std::cell::Cell; +#[cfg(feature = "trace")] +use bevy_utils::tracing::info_span; use thread_local::ThreadLocal; use crate::{ @@ -52,7 +54,7 @@ impl SystemBuffer for ParallelCommandQueue { #[inline] fn apply(&mut self, _system_meta: &SystemMeta, world: &mut World) { #[cfg(feature = "trace")] - let _system_span = _system_meta.commands_span.enter(); + let _system_span = info_span!("system_commands", name = _system_meta.name()).entered(); for cq in &mut self.thread_local_storage { cq.get_mut().apply(world); } diff --git a/crates/bevy_ecs/src/system/exclusive_function_system.rs b/crates/bevy_ecs/src/system/exclusive_function_system.rs index 1d9e1241d2232..794231d56b7b6 100644 --- a/crates/bevy_ecs/src/system/exclusive_function_system.rs +++ b/crates/bevy_ecs/src/system/exclusive_function_system.rs @@ -11,6 +11,8 @@ use crate::{ }; use bevy_utils::all_tuples; +#[cfg(feature = "trace")] +use bevy_utils::tracing::info_span; use std::{any::TypeId, borrow::Cow, marker::PhantomData}; /// A function system that runs with exclusive [`World`] access. @@ -106,7 +108,7 @@ where fn run(&mut self, input: Self::In, world: &mut World) -> Self::Out { #[cfg(feature = "trace")] - let _span_guard = self.system_meta.system_span.enter(); + let _span_guard = info_span!("system", name = self.name().as_ref()).entered(); let saved_last_tick = world.last_change_tick; world.last_change_tick = self.system_meta.last_run; diff --git a/crates/bevy_ecs/src/system/function_system.rs b/crates/bevy_ecs/src/system/function_system.rs index 9056a1648153e..dcd19c539fa2f 100644 --- a/crates/bevy_ecs/src/system/function_system.rs +++ b/crates/bevy_ecs/src/system/function_system.rs @@ -9,10 +9,9 @@ use crate::{ }; use bevy_utils::all_tuples; -use std::{any::TypeId, borrow::Cow, marker::PhantomData}; - #[cfg(feature = "trace")] -use bevy_utils::tracing::{info_span, Span}; +use bevy_utils::tracing::info_span; +use std::{any::TypeId, borrow::Cow, marker::PhantomData}; use super::{In, IntoSystem, ReadOnlySystem}; @@ -27,10 +26,6 @@ pub struct SystemMeta { is_send: bool, has_deferred: bool, pub(crate) last_run: Tick, - #[cfg(feature = "trace")] - pub(crate) system_span: Span, - #[cfg(feature = "trace")] - pub(crate) commands_span: Span, } impl SystemMeta { @@ -43,10 +38,6 @@ impl SystemMeta { is_send: true, has_deferred: false, last_run: Tick::new(0), - #[cfg(feature = "trace")] - system_span: info_span!("system", name = name), - #[cfg(feature = "trace")] - commands_span: info_span!("system_commands", name = name), } } @@ -486,7 +477,7 @@ where #[inline] unsafe fn run_unsafe(&mut self, input: Self::In, world: UnsafeWorldCell) -> Self::Out { #[cfg(feature = "trace")] - let _span_guard = self.system_meta.system_span.enter(); + let _span_guard = info_span!("system", name = self.name().as_ref()).entered(); let change_tick = world.increment_change_tick();