Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - More Bevy ECS schedule spans #3281

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions crates/bevy_ecs/src/schedule/executor_parallel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ impl ParallelExecutor {
/// Calls system.new_archetype() for each archetype added since the last call to
/// [update_archetypes] and updates cached archetype_component_access.
fn update_archetypes(&mut self, systems: &mut [ParallelSystemContainer], world: &World) {
#[cfg(feature = "trace")]
let span = bevy_utils::tracing::info_span!("update_archetypes");
#[cfg(feature = "trace")]
let _guard = span.enter();
let archetypes = world.archetypes();
let new_generation = archetypes.generation();
let old_generation = std::mem::replace(&mut self.archetype_generation, new_generation);
Expand All @@ -174,6 +178,10 @@ impl ParallelExecutor {
systems: &'scope [ParallelSystemContainer],
world: &'scope World,
) {
#[cfg(feature = "trace")]
let span = bevy_utils::tracing::info_span!("prepare_systems");
#[cfg(feature = "trace")]
let _guard = span.enter();
self.should_run.clear();
for (index, system_data) in self.system_metadata.iter_mut().enumerate() {
// Spawn the system task.
Expand Down
28 changes: 28 additions & 0 deletions crates/bevy_ecs/src/schedule/stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,13 @@ impl Stage for SystemStage {
// Run systems that want to be at the start of stage.
for container in &mut self.exclusive_at_start {
if should_run(container, &self.run_criteria, default_should_run) {
#[cfg(feature = "trace")]
let system_span = bevy_utils::tracing::info_span!(
"exclusive_system",
name = &*container.name()
);
#[cfg(feature = "trace")]
let _guard = system_span.enter();
container.system_mut().run(world);
}
}
Expand All @@ -845,6 +852,13 @@ impl Stage for SystemStage {
// Run systems that want to be between parallel systems and their command buffers.
for container in &mut self.exclusive_before_commands {
if should_run(container, &self.run_criteria, default_should_run) {
#[cfg(feature = "trace")]
let system_span = bevy_utils::tracing::info_span!(
"exclusive_system",
name = &*container.name()
);
#[cfg(feature = "trace")]
let _guard = system_span.enter();
container.system_mut().run(world);
}
}
Expand All @@ -853,6 +867,13 @@ impl Stage for SystemStage {
if self.apply_buffers {
for container in &mut self.parallel {
if container.should_run {
#[cfg(feature = "trace")]
let span = bevy_utils::tracing::info_span!(
"system_commands",
name = &*container.name()
);
#[cfg(feature = "trace")]
let _guard = span.enter();
container.system_mut().apply_buffers(world);
}
}
Expand All @@ -861,6 +882,13 @@ impl Stage for SystemStage {
// Run systems that want to be at the end of stage.
for container in &mut self.exclusive_at_end {
if should_run(container, &self.run_criteria, default_should_run) {
#[cfg(feature = "trace")]
let system_span = bevy_utils::tracing::info_span!(
"exclusive_system",
name = &*container.name()
);
#[cfg(feature = "trace")]
let _guard = system_span.enter();
container.system_mut().run(world);
}
}
Expand Down