Skip to content

Commit

Permalink
Re-add the "frame" span for tracy comparisons (#8362)
Browse files Browse the repository at this point in the history
# Objective

In #6503 there were two changes
to the top level tracing span "frame. Firstly it was renamed to "main
app" and secondly the scope was reduced to *only* the main app. This
means that there is no longer a top level span that can be used to
compare frame times.

In addition to making it easier to compare across versions again, it
also helps when running without the render feature. Previously the
"frame" span was present in both cases but now to compare "headless" and
render the comparison is between "main app" and "winit event_handler"
and Tracy doesn't handle comparing non-matching frames well.

Before (0.9)

![image](https://user-images.githubusercontent.com/1353401/231454801-5690fb40-f9c1-4c64-b7b3-cebb15f1d16a.png)

After (0.10)

![image](https://user-images.githubusercontent.com/1353401/231454926-df76e7d3-b5fa-49bc-a56c-67301d2a9e8a.png)



## Solution

This PR reintroduces the "frame" span so comparisons across versions and
features is again easy.


![image](https://user-images.githubusercontent.com/1353401/231455114-94f86d22-64de-48fc-9a0f-a5c607d3f350.png)


![image](https://user-images.githubusercontent.com/1353401/231455182-fe27a646-b55e-4bfb-8e05-c4690f52c550.png)

### Alternative

As an alternative route, the `tracy-client` crate that is used by
`tracing-tracy` supports the ability to set multiple "Frame" markers
using the `secondary_mark_frame` function. It may be possible to create
a PR for `tracing-tracy` that exposes that functionality and then
publish an "update" frame marker instead. This might have additional
benefits in the future as it could be used for other systems we might
want to track as frames without endless nesting.
  • Loading branch information
MJohnson459 committed Apr 25, 2023
1 parent 6f291a0 commit dea91e9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crates/bevy_app/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,11 @@ impl App {
///
/// The active schedule of the app must be set before this method is called.
pub fn update(&mut self) {
#[cfg(feature = "trace")]
let _bevy_update_span = info_span!("update").entered();
{
#[cfg(feature = "trace")]
let _bevy_frame_update_span = info_span!("main app").entered();
let _bevy_main_update_span = info_span!("main app").entered();
self.world.run_schedule(&*self.main_schedule_label);
}
for (_label, sub_app) in self.sub_apps.iter_mut() {
Expand Down

0 comments on commit dea91e9

Please sign in to comment.