Skip to content

Commit

Permalink
cache spans for commands
Browse files Browse the repository at this point in the history
  • Loading branch information
hymm committed Aug 9, 2023
1 parent 28ab036 commit 3fec176
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 1 addition & 3 deletions crates/bevy_ecs/src/system/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,7 @@ impl SystemBuffer for CommandQueue {
#[inline]
fn apply(&mut self, _system_meta: &SystemMeta, world: &mut World) {
#[cfg(feature = "trace")]
let _system_span =
bevy_utils::tracing::info_span!("system_commands", name = _system_meta.name())
.entered();
let _span_guard = _system_meta.commands_span.enter();
self.apply(world);
}
}
Expand Down
4 changes: 1 addition & 3 deletions crates/bevy_ecs/src/system/commands/parallel_scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ impl SystemBuffer for ParallelCommandQueue {
#[inline]
fn apply(&mut self, _system_meta: &SystemMeta, world: &mut World) {
#[cfg(feature = "trace")]
let _system_span =
bevy_utils::tracing::info_span!("system_commands", name = _system_meta.name())
.entered();
let _system_span = _system_meta.commands_span.enter();
for cq in &mut self.thread_local_storage {
cq.get_mut().apply(world);
}
Expand Down
10 changes: 9 additions & 1 deletion crates/bevy_ecs/src/system/function_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,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 super::{In, IntoSystem, ReadOnlySystem};

/// The metadata of a [`System`].
Expand All @@ -22,16 +25,21 @@ pub struct SystemMeta {
// SystemParams from overriding each other
is_send: bool,
pub(crate) last_run: Tick,
#[cfg(feature = "trace")]
pub(crate) commands_span: Span,
}

impl SystemMeta {
pub(crate) fn new<T>() -> Self {
let name = std::any::type_name::<T>();
Self {
name: std::any::type_name::<T>().into(),
name: name.into(),
archetype_component_access: Access::default(),
component_access_set: FilteredAccessSet::default(),
is_send: true,
last_run: Tick::new(0),
#[cfg(feature = "trace")]
commands_span: info_span!("system_commands", name = &*name),
}
}

Expand Down

0 comments on commit 3fec176

Please sign in to comment.