Skip to content

Commit

Permalink
Automatic System Spans (bevyengine#2033)
Browse files Browse the repository at this point in the history
As mentioned in bevyengine#2025 (comment), systems used to have spans by default.

* add spans by default for every system executed
* create folder if missing for feature `wgpu_trace`
  • Loading branch information
mockersf authored and ostwilkens committed Jul 27, 2021
1 parent bc7f56e commit 3afa0bb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions crates/bevy_ecs/src/schedule/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ impl ParallelSystemExecutor for SingleThreadedExecutor {

for system in systems {
if system.should_run() {
#[cfg(feature = "trace")]
let system_span = bevy_utils::tracing::info_span!("system", name = &*system.name());
#[cfg(feature = "trace")]
let _system_guard = system_span.enter();
system.system_mut().run((), world);
}
}
Expand Down
7 changes: 7 additions & 0 deletions crates/bevy_ecs/src/schedule/executor_parallel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,14 @@ impl ParallelExecutor {
.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")]
drop(system_guard);
finish_sender
.send(index)
.await
Expand Down
7 changes: 6 additions & 1 deletion crates/bevy_wgpu/src/wgpu_renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ impl WgpuRenderer {
.expect("Unable to find a GPU! Make sure you have installed required drivers!");

#[cfg(feature = "trace")]
let trace_path = Some(std::path::Path::new("wgpu_trace"));
let trace_path = {
let path = std::path::Path::new("wgpu_trace");
// ignore potential error, wgpu will log it
let _ = std::fs::create_dir(path);
Some(path)
};
#[cfg(not(feature = "trace"))]
let trace_path = None;

Expand Down

0 comments on commit 3afa0bb

Please sign in to comment.