[tracing] Avoid perfetto track aliasing in chrome/browser/page_load_metrics
perfetto::Track::FromPointer is problematic because pointer reuse can
cause track aliasing in perfetto UI, leading to confusing traces
(this was true of legacy TRACE_EVENT_ASYNC as well).
To avoid these, we have the following alternatives:
1- Using GetNextGlobalTraceId() instead of a pointer id to guarantee uniqueness.
The track will get its name from the first event emitted.
2- Using NamedTrack to scope the pointer to a specific class
(an aliased track would always correctly have the same name). This is more
appropriate when there are several events emitted to the same track without a
clear name. This has the benefit of giving the track a consistent, explicit name.
3- Replace custom track with "sync" instant events with flows. This reduces visual
clutter and retain information about where events originated from.
This CL applies a migration to of one #1 or #2.
Questions for the reviewer:
- Design Fit: Is the choice of a dedicated async track (#1/#2) appropriate, or
would is be suitable to emit "sync" events with flows (#3). As a rule of thumb,
async tracks are appropriate to display a clear async operation
(that could be recorded as UMA), or high level / user visible state.
- Naming: (when applicable) Is the track name I chose appropriate
This CL was uploaded by git cl split.
diff --git a/chrome/browser/page_load_metrics/observers/lcp_critical_path_predictor_page_load_metrics_observer.cc b/chrome/browser/page_load_metrics/observers/lcp_critical_path_predictor_page_load_metrics_observer.cc
index fa1b5f63..cb8a1eb 100644
--- a/chrome/browser/page_load_metrics/observers/lcp_critical_path_predictor_page_load_metrics_observer.cc
+++ b/chrome/browser/page_load_metrics/observers/lcp_critical_path_predictor_page_load_metrics_observer.cc
@@ -834,10 +834,11 @@
"Blink.LCPP.NavigationToStartPreload.MainFrame.FirstSubresource.Time",
subresource_load_start);
const base::TimeTicks navigation_start = GetDelegate().GetNavigationStart();
- TRACE_EVENT_BEGIN("loading", "NavigationToStartFirstPreload",
- perfetto::Track::FromPointer(this), navigation_start,
- "url", subresource_url);
- TRACE_EVENT_END("loading", perfetto::Track::FromPointer(this),
+ auto track = perfetto::NamedTrack::FromPointer(
+ "NavigationToStartFirstPreload", this);
+ TRACE_EVENT_BEGIN("loading", "NavigationToStartFirstPreload", track,
+ navigation_start, "url", subresource_url);
+ TRACE_EVENT_END("loading", track,
navigation_start + subresource_load_start);
}
base::UmaHistogramMediumTimes(
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Auto-Submit | +1 |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
[tracing] Avoid perfetto track aliasing in chrome/browser/page_load_metrics
perfetto::Track::FromPointer is problematic because pointer reuse can
cause track aliasing in perfetto UI, leading to confusing traces (this
was true of legacy TRACE_EVENT_ASYNC as well).
In this case, I removed the events, since NavigationToStartFirstPreload
is deprecated.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |