Skip to content

Commit

Permalink
Fix bevy_ecs::schedule::executor_parallel::system span management (#2905
Browse files Browse the repository at this point in the history
)

# Objective

- Fixes #2904 (see for context)

## Solution

- Simply hoist span creation out of the threaded task
- Confirmed to solve the issue locally

Now all events have the full span parent tree up through `bevy_ecs::schedule::stage` all the way to `bevy_app::app::bevy_app` (and its parents in bevy-consumer code, if any).
  • Loading branch information
CAD97 committed Oct 6, 2021
1 parent a60fe30 commit 0887f41
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions crates/bevy_ecs/src/schedule/executor_parallel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,14 @@ impl ParallelExecutor {
let start_receiver = system_data.start_receiver.clone();
let finish_sender = self.finish_sender.clone();
let system = unsafe { systems[index].system_mut_unsafe() };
#[cfg(feature = "trace")] // NB: outside the task to get the TLS current span
let system_span = bevy_utils::tracing::info_span!("system", name = &*system.name());
let task = async move {
start_receiver
.recv()
.await
.unwrap_or_else(|error| unreachable!(error));
#[cfg(feature = "trace")]
let system_span =
bevy_utils::tracing::info_span!("system", name = &*system.name());
#[cfg(feature = "trace")]
let system_guard = system_span.enter();
unsafe { system.run_unsafe((), world) };
#[cfg(feature = "trace")]
Expand Down

0 comments on commit 0887f41

Please sign in to comment.