Re-add the "frame" span for tracy comparisons (#8362)

# Objective

In https://github.com/bevyengine/bevy/pull/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.
This commit is contained in:
Michael Johnson 2023-04-25 15:56:05 +01:00 committed by GitHub
parent 6f291a037f
commit dea91e94d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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() {