From c9c92ba6bd4f91ae681a36260fd49a8cbfdf1ba9 Mon Sep 17 00:00:00 2001 From: Bas Schouten Date: Mon, 11 Mar 2024 16:38:22 +0000 Subject: [PATCH] Bug 1884213 - Part 4: Convert Text and Tracing markers to use BaseMarkerType so they gain ETW support. r=mstange,profiler-reviewers Differential Revision: https://phabricator.services.mozilla.com/D203985 --- .../baseprofiler/public/BaseProfilerMarkers.h | 59 +++++++++++-------- .../public/BaseProfilerMarkersPrerequisites.h | 4 +- 2 files changed, 37 insertions(+), 26 deletions(-) diff --git a/mozglue/baseprofiler/public/BaseProfilerMarkers.h b/mozglue/baseprofiler/public/BaseProfilerMarkers.h index d706cefd4ab4..6d0b4e74e769 100644 --- a/mozglue/baseprofiler/public/BaseProfilerMarkers.h +++ b/mozglue/baseprofiler/public/BaseProfilerMarkers.h @@ -138,45 +138,54 @@ inline ProfileBufferBlockIndex AddMarker(const ProfilerString8View& aName, namespace mozilla::baseprofiler::markers { // Most common marker type. Others are in BaseProfilerMarkerTypes.h. -struct TextMarker { - static constexpr Span MarkerTypeName() { - return MakeStringSpan("Text"); - } +struct TextMarker : public BaseMarkerType { + static constexpr const char* Name = "Text"; + static constexpr const char* Description = "Generic text marker"; + + static constexpr bool StoreName = true; + + using MS = MarkerSchema; + static constexpr MS::PayloadField PayloadFields[] = + // XXX - This is confusingly labeled 'name'. We probably want to fix that. + {{"name", MS::InputType::CString, "Details", MS::Format::String, + MS::PayloadFlags::Searchable}}; + + static constexpr MS::Location Locations[] = {MS::Location::MarkerChart, + MS::Location::MarkerTable}; + + static constexpr const char* ChartLabel = "{marker.data.name}"; + static constexpr const char* TableLabel = + "{marker.name} - {marker.data.name}"; + static void StreamJSONMarkerData(baseprofiler::SpliceableJSONWriter& aWriter, const ProfilerString8View& aText) { aWriter.StringProperty("name", aText); } - static MarkerSchema MarkerTypeDisplay() { - using MS = MarkerSchema; - MS schema{MS::Location::MarkerChart, MS::Location::MarkerTable}; - schema.SetChartLabel("{marker.data.name}"); - schema.SetTableLabel("{marker.name} - {marker.data.name}"); - schema.AddKeyLabelFormatSearchable("name", "Details", MS::Format::String, - MS::Searchable::Searchable); - return schema; - } }; // Keep this struct in sync with the `gecko_profiler::marker::Tracing` Rust // counterpart. -struct Tracing { - static constexpr Span MarkerTypeName() { - return MakeStringSpan("tracing"); - } +struct Tracing : public BaseMarkerType { + static constexpr const char* Name = "tracing"; + static constexpr const char* Description = "Generic tracing marker"; + + static constexpr bool StoreName = true; + + using MS = MarkerSchema; + static constexpr MS::PayloadField PayloadFields[] = { + {"category", MS::InputType::CString, "Type", MS::Format::String, + MS::PayloadFlags::Searchable}}; + + static constexpr MS::Location Locations[] = {MS::Location::MarkerChart, + MS::Location::MarkerTable, + MS::Location::TimelineOverview}; + static void StreamJSONMarkerData(SpliceableJSONWriter& aWriter, const ProfilerString8View& aCategory) { if (aCategory.Length() != 0) { aWriter.StringProperty("category", aCategory); } } - static MarkerSchema MarkerTypeDisplay() { - using MS = MarkerSchema; - MS schema{MS::Location::MarkerChart, MS::Location::MarkerTable, - MS::Location::TimelineOverview}; - schema.AddKeyLabelFormatSearchable("category", "Type", MS::Format::String, - MS::Searchable::Searchable); - return schema; - } }; } // namespace mozilla::baseprofiler::markers diff --git a/mozglue/baseprofiler/public/BaseProfilerMarkersPrerequisites.h b/mozglue/baseprofiler/public/BaseProfilerMarkersPrerequisites.h index 0162f8093e4b..c1de8955a7e5 100644 --- a/mozglue/baseprofiler/public/BaseProfilerMarkersPrerequisites.h +++ b/mozglue/baseprofiler/public/BaseProfilerMarkersPrerequisites.h @@ -784,7 +784,9 @@ class MarkerSchema { Generic = 1, UserMarkers = 1 << 1, Memory = 1 << 2, - Scheduling = 1 << 3 + Scheduling = 1 << 3, + Text = 1 << 4, + Tracing = 1 << 5 }; // Flags which describe additional information for a PayloadField.