Skip to content

Commit

Permalink
Fix spans for system
Browse files Browse the repository at this point in the history
  • Loading branch information
stepancheg committed Jan 1, 2024
1 parent 71adb77 commit 48f115d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
4 changes: 3 additions & 1 deletion crates/bevy_ecs/src/system/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down Expand Up @@ -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);
}
}
Expand Down
4 changes: 3 additions & 1 deletion crates/bevy_ecs/src/system/commands/parallel_scope.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use std::cell::Cell;

#[cfg(feature = "trace")]
use bevy_utils::tracing::info_span;
use thread_local::ThreadLocal;

use crate::{
Expand Down Expand Up @@ -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);
}
Expand Down
4 changes: 3 additions & 1 deletion crates/bevy_ecs/src/system/exclusive_function_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand Down
15 changes: 3 additions & 12 deletions crates/bevy_ecs/src/system/function_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand All @@ -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 {
Expand All @@ -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),
}
}

Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit 48f115d

Please sign in to comment.