diff --git a/dom/events/EventDispatcher.cpp b/dom/events/EventDispatcher.cpp index 42f064c41e7a..985036a8bffe 100644 --- a/dom/events/EventDispatcher.cpp +++ b/dom/events/EventDispatcher.cpp @@ -1059,6 +1059,17 @@ nsresult EventDispatcher::Dispatch(nsISupports* aTarget, aWriter.DoubleProperty( "latency", (aStartTime - aEventTimeStamp).ToMilliseconds()); } + static MarkerSchema MarkerTypeDisplay() { + using MS = MarkerSchema; + MS schema{MS::Location::markerChart, MS::Location::markerTable, + MS::Location::timelineOverview}; + schema.SetChartLabel("{marker.data.eventType}"); + schema.SetTooltipLabel("{marker.data.eventType} - DOMEvent"); + schema.SetTableLabel("{marker.data.eventType}"); + schema.AddKeyLabelFormat("latency", "Latency", + MS::Format::duration); + return schema; + } }; auto startTime = TimeStamp::NowUnfuzzed(); diff --git a/mozglue/baseprofiler/public/BaseProfilerMarkerTypes.h b/mozglue/baseprofiler/public/BaseProfilerMarkerTypes.h index 78295aca5f53..3f398b7b2eb8 100644 --- a/mozglue/baseprofiler/public/BaseProfilerMarkerTypes.h +++ b/mozglue/baseprofiler/public/BaseProfilerMarkerTypes.h @@ -39,6 +39,13 @@ struct Tracing { aWriter.StringProperty("category", aCategory); } } + static MarkerSchema MarkerTypeDisplay() { + using MS = MarkerSchema; + MS schema{MS::Location::markerChart, MS::Location::markerTable, + MS::Location::timelineOverview}; + schema.AddKeyLabelFormat("category", "Type", MS::Format::string); + return schema; + } }; struct FileIO { @@ -59,11 +66,25 @@ struct FileIO { aWriter.IntProperty("threadId", aOperationThreadId.ThreadId()); } } + static MarkerSchema MarkerTypeDisplay() { + using MS = MarkerSchema; + MS schema{MS::Location::markerChart, MS::Location::markerTable, + MS::Location::timelineFileIO}; + schema.AddKeyLabelFormatSearchable("operation", "Operation", + MS::Format::string, + MS::Searchable::searchable); + schema.AddKeyLabelFormatSearchable("source", "Source", MS::Format::string, + MS::Searchable::searchable); + schema.AddKeyLabelFormatSearchable("filename", "Filename", + MS::Format::filePath, + MS::Searchable::searchable); + return schema; + } }; struct UserTimingMark { static constexpr Span MarkerTypeName() { - return MakeStringSpan("UserTiming"); + return MakeStringSpan("UserTimingMark"); } static void StreamJSONMarkerData(JSONWriter& aWriter, const ProfilerString8View& aName) { @@ -72,11 +93,23 @@ struct UserTimingMark { aWriter.NullProperty("startMark"); aWriter.NullProperty("endMark"); } + static MarkerSchema MarkerTypeDisplay() { + using MS = MarkerSchema; + MS schema{MS::Location::markerChart, MS::Location::markerTable}; + schema.SetAllLabels("{marker.data.name}"); + schema.AddStaticLabelValue("Marker", "UserTiming"); + schema.AddKeyLabelFormat("entryType", "Entry Type", MS::Format::string); + schema.AddKeyLabelFormat("name", "Name", MS::Format::string); + schema.AddStaticLabelValue( + "Description", + "UserTimingMark is created using the DOM API performance.mark()."); + return schema; + } }; struct UserTimingMeasure { static constexpr Span MarkerTypeName() { - return MakeStringSpan("UserTiming"); + return MakeStringSpan("UserTimingMeasure"); } static void StreamJSONMarkerData(JSONWriter& aWriter, const ProfilerString8View& aName, @@ -96,6 +129,20 @@ struct UserTimingMeasure { aWriter.NullProperty("endMark"); } } + static MarkerSchema MarkerTypeDisplay() { + using MS = MarkerSchema; + MS schema{MS::Location::markerChart, MS::Location::markerTable}; + schema.SetAllLabels("{marker.data.name}"); + schema.AddStaticLabelValue("Marker", "UserTiming"); + schema.AddKeyLabelFormat("entryType", "Entry Type", MS::Format::string); + schema.AddKeyLabelFormat("name", "Name", MS::Format::string); + schema.AddKeyLabelFormat("startMark", "Start Mark", MS::Format::string); + schema.AddKeyLabelFormat("endMark", "End Mark", MS::Format::string); + schema.AddStaticLabelValue("Description", + "UserTimingMeasure is created using the DOM API " + "performance.measure()."); + return schema; + } }; struct Hang { @@ -103,6 +150,12 @@ struct Hang { return MakeStringSpan("BHR-detected hang"); } static void StreamJSONMarkerData(JSONWriter& aWriter) {} + static MarkerSchema MarkerTypeDisplay() { + using MS = MarkerSchema; + MS schema{MS::Location::markerChart, MS::Location::markerTable, + MS::Location::timelineOverview}; + return schema; + } }; struct LongTask { @@ -112,6 +165,12 @@ struct LongTask { static void StreamJSONMarkerData(JSONWriter& aWriter) { aWriter.StringProperty("category", "LongTask"); } + static MarkerSchema MarkerTypeDisplay() { + using MS = MarkerSchema; + MS schema{MS::Location::markerChart, MS::Location::markerTable}; + schema.AddKeyLabelFormat("category", "Type", MS::Format::string); + return schema; + } }; struct Log { @@ -124,6 +183,14 @@ struct Log { aWriter.StringProperty("module", aModule); aWriter.StringProperty("name", aText); } + static MarkerSchema MarkerTypeDisplay() { + using MS = MarkerSchema; + MS schema{MS::Location::markerTable}; + schema.SetTableLabel("({marker.data.module}) {marker.data.name}"); + schema.AddKeyLabelFormat("module", "Module", MS::Format::string); + schema.AddKeyLabelFormat("name", "Name", MS::Format::string); + return schema; + } }; struct MediaSample { @@ -136,6 +203,15 @@ struct MediaSample { aWriter.IntProperty("sampleStartTimeUs", aSampleStartTimeUs); aWriter.IntProperty("sampleEndTimeUs", aSampleEndTimeUs); } + static MarkerSchema MarkerTypeDisplay() { + using MS = MarkerSchema; + MS schema{MS::Location::markerChart, MS::Location::markerTable}; + schema.AddKeyLabelFormat("sampleStartTimeUs", "Sample start time", + MS::Format::microseconds); + schema.AddKeyLabelFormat("sampleEndTimeUs", "Sample end time", + MS::Format::microseconds); + return schema; + } }; } // namespace mozilla::baseprofiler::markers diff --git a/mozglue/baseprofiler/public/BaseProfilerMarkers.h b/mozglue/baseprofiler/public/BaseProfilerMarkers.h index 46e201b9e20a..d9adc71a148c 100644 --- a/mozglue/baseprofiler/public/BaseProfilerMarkers.h +++ b/mozglue/baseprofiler/public/BaseProfilerMarkers.h @@ -154,6 +154,15 @@ struct Text { const ProfilerString8View& aText) { aWriter.StringProperty("name", aText); } + static mozilla::MarkerSchema MarkerTypeDisplay() { + using MS = mozilla::MarkerSchema; + MS schema{MS::Location::markerChart, MS::Location::markerTable}; + schema.SetChartLabel("{marker.name} - {marker.data.name}"); + schema.SetTableLabel("{marker.name} - {marker.data.name}"); + schema.AddKeyLabelFormat("name", "Details", + mozilla::MarkerSchema::Format::string); + return schema; + } }; } // namespace mozilla::baseprofiler::markers diff --git a/mozglue/baseprofiler/public/BaseProfilerMarkersDetail.h b/mozglue/baseprofiler/public/BaseProfilerMarkersDetail.h index 6445da9e26f0..4bd3ff5fd0eb 100644 --- a/mozglue/baseprofiler/public/BaseProfilerMarkersDetail.h +++ b/mozglue/baseprofiler/public/BaseProfilerMarkersDetail.h @@ -197,6 +197,12 @@ static ProfileBufferBlockIndex AddMarkerWithOptionalStackToBuffer( static void StreamJSONMarkerData(JSONWriter& aWriter) { // No user payload. } + static mozilla::MarkerSchema MarkerTypeDisplay() { + using MS = mozilla::MarkerSchema; + MS schema{MS::Location::markerChart, MS::Location::markerTable}; + // No user data to display. + return schema; + } }; return MarkerTypeSerialization::Serialize( aBuffer, aName, aCategory, std::move(aOptions)); diff --git a/mozglue/tests/TestBaseProfiler.cpp b/mozglue/tests/TestBaseProfiler.cpp index 6c8999f03f98..d6337036e9cd 100644 --- a/mozglue/tests/TestBaseProfiler.cpp +++ b/mozglue/tests/TestBaseProfiler.cpp @@ -3781,8 +3781,8 @@ void TestMarkerNoPayload() { void TestUserMarker() { printf("TestUserMarker...\n"); - // User-defined marker type with text. If there are no `Convert` functions, - // it's fine to define it right in the function where it's used. + // User-defined marker type with text. + // It's fine to define it right in the function where it's used. struct MarkerTypeTestMinimal { static constexpr Span MarkerTypeName() { return MakeStringSpan("test-minimal"); @@ -3791,6 +3791,14 @@ void TestUserMarker() { const std::string& aText) { aWriter.StringProperty("text", aText); } + static mozilla::MarkerSchema MarkerTypeDisplay() { + using MS = mozilla::MarkerSchema; + MS schema{MS::Location::markerChart, MS::Location::markerTable}; + schema.SetTooltipLabel("tooltip for test-minimal"); + schema.AddKeyLabelFormatSearchable("text", "Text", MS::Format::string, + MS::Searchable::searchable); + return schema; + } }; mozilla::ProfileBufferChunkManagerSingle chunkManager(1024); @@ -3859,18 +3867,6 @@ void TestUserMarker() { void TestPredefinedMarkers() { printf("TestPredefinedMarkers...\n"); - // User-defined marker type with text. If there are no `Convert` functions, - // it's fine to define it right in the function where it's used. - struct MarkerTypeTestMinimal { - static constexpr Span MarkerTypeName() { - return MakeStringSpan("test-minimal"); - } - static void StreamJSONMarkerData(mozilla::JSONWriter& aWriter, - const std::string& aText) { - aWriter.StringProperty("text", aText); - } - }; - mozilla::ProfileBufferChunkManagerSingle chunkManager(1024); mozilla::ProfileChunkedBuffer buffer( mozilla::ProfileChunkedBuffer::ThreadSafety::WithoutMutex, chunkManager); diff --git a/tools/profiler/public/ProfilerMarkerTypes.h b/tools/profiler/public/ProfilerMarkerTypes.h index 3d60747aa070..45f7362e6327 100644 --- a/tools/profiler/public/ProfilerMarkerTypes.h +++ b/tools/profiler/public/ProfilerMarkerTypes.h @@ -50,6 +50,12 @@ struct Budget { return mozilla::MakeStringSpan("Budget"); } static void StreamJSONMarkerData(mozilla::JSONWriter& aWriter) {} + static mozilla::MarkerSchema MarkerTypeDisplay() { + using MS = mozilla::MarkerSchema; + MS schema{MS::Location::markerChart, MS::Location::markerTable}; + // Nothing outside the defaults. + return schema; + } }; struct Pref { @@ -72,6 +78,15 @@ struct Pref { aWriter.StringProperty("prefType", PrefTypeToString(aPrefType)); aWriter.StringProperty("prefValue", aPrefValue); } + static mozilla::MarkerSchema MarkerTypeDisplay() { + using MS = mozilla::MarkerSchema; + MS schema{MS::Location::markerChart, MS::Location::markerTable}; + schema.AddKeyLabelFormat("prefName", "Name", MS::Format::string); + schema.AddKeyLabelFormat("prefKind", "Kind", MS::Format::string); + schema.AddKeyLabelFormat("prefType", "Type", MS::Format::string); + schema.AddKeyLabelFormat("prefValue", "Value", MS::Format::string); + return schema; + } private: static mozilla::Span PrefValueKindToString( @@ -121,6 +136,14 @@ struct LayerTranslation { aWriter.IntProperty("x", aPoint.x); aWriter.IntProperty("y", aPoint.y); } + static mozilla::MarkerSchema MarkerTypeDisplay() { + using MS = mozilla::MarkerSchema; + MS schema{MS::Location::markerChart, MS::Location::markerTable}; + schema.AddKeyLabelFormat("layer", "Layer", MS::Format::string); + schema.AddKeyLabelFormat("x", "X", MS::Format::integer); + schema.AddKeyLabelFormat("y", "Y", MS::Format::integer); + return schema; + } }; // Tracks when a vsync occurs according to the HardwareComposer. @@ -129,6 +152,12 @@ struct Vsync { return mozilla::MakeStringSpan("VsyncTimestamp"); } static void StreamJSONMarkerData(mozilla::JSONWriter& aWriter) {} + static mozilla::MarkerSchema MarkerTypeDisplay() { + using MS = mozilla::MarkerSchema; + MS schema{MS::Location::markerChart, MS::Location::markerTable}; + // Nothing outside the defaults. + return schema; + } }; struct Network { @@ -196,6 +225,9 @@ struct Network { aTimings.responseEnd); } } + static mozilla::MarkerSchema MarkerTypeDisplay() { + return mozilla::MarkerSchema::SpecialFrontendLocation{}; + } private: static mozilla::Span GetNetworkState(NetworkLoadType aType) { @@ -249,6 +281,9 @@ struct ScreenshotPayload { aWriter.DoubleProperty("windowWidth", aWindowSize.width); aWriter.DoubleProperty("windowHeight", aWindowSize.height); } + static mozilla::MarkerSchema MarkerTypeDisplay() { + return mozilla::MarkerSchema::SpecialFrontendLocation{}; + } }; struct GCSlice { @@ -266,6 +301,13 @@ struct GCSlice { aWriter.NullProperty("timings"); } } + static mozilla::MarkerSchema MarkerTypeDisplay() { + using MS = mozilla::MarkerSchema; + MS schema{MS::Location::markerChart, MS::Location::markerTable, + MS::Location::timelineMemory}; + // No display instructions here, there is special handling in the front-end. + return schema; + } }; struct GCMajor { @@ -283,6 +325,13 @@ struct GCMajor { aWriter.NullProperty("timings"); } } + static mozilla::MarkerSchema MarkerTypeDisplay() { + using MS = mozilla::MarkerSchema; + MS schema{MS::Location::markerChart, MS::Location::markerTable, + MS::Location::timelineMemory}; + // No display instructions here, there is special handling in the front-end. + return schema; + } }; struct GCMinor { @@ -300,6 +349,13 @@ struct GCMinor { aWriter.NullProperty("nursery"); } } + static mozilla::MarkerSchema MarkerTypeDisplay() { + using MS = mozilla::MarkerSchema; + MS schema{MS::Location::markerChart, MS::Location::markerTable, + MS::Location::timelineMemory}; + // No display instructions here, there is special handling in the front-end. + return schema; + } }; struct StyleMarkerPayload { @@ -309,13 +365,28 @@ struct StyleMarkerPayload { static void StreamJSONMarkerData( mozilla::JSONWriter& aWriter, const mozilla::ServoTraversalStatistics& aStats) { - aWriter.StringProperty("category", "Paint"); aWriter.IntProperty("elementsTraversed", aStats.mElementsTraversed); aWriter.IntProperty("elementsStyled", aStats.mElementsStyled); aWriter.IntProperty("elementsMatched", aStats.mElementsMatched); aWriter.IntProperty("stylesShared", aStats.mStylesShared); aWriter.IntProperty("stylesReused", aStats.mStylesReused); } + static mozilla::MarkerSchema MarkerTypeDisplay() { + using MS = mozilla::MarkerSchema; + MS schema{MS::Location::markerChart, MS::Location::markerTable, + MS::Location::timelineOverview}; + schema.AddKeyLabelFormat("elementsTraversed", "Elements traversed", + MS::Format::integer); + schema.AddKeyLabelFormat("elementsStyled", "Elements styled", + MS::Format::integer); + schema.AddKeyLabelFormat("elementsMatched", "Elements matched", + MS::Format::integer); + schema.AddKeyLabelFormat("stylesShared", "Styles shared", + MS::Format::integer); + schema.AddKeyLabelFormat("stylesReused", "Styles reused", + MS::Format::integer); + return schema; + } }; class JsAllocationMarkerPayload { @@ -347,6 +418,9 @@ class JsAllocationMarkerPayload { aWriter.IntProperty("size", aSize); aWriter.BoolProperty("inNursery", aInNursery); } + static mozilla::MarkerSchema MarkerTypeDisplay() { + return mozilla::MarkerSchema::SpecialFrontendLocation{}; + } }; // This payload is for collecting information about native allocations. There is @@ -362,6 +436,9 @@ struct NativeAllocationMarkerPayload { aWriter.IntProperty("memoryAddress", static_cast(aMemoryAddress)); aWriter.IntProperty("threadId", aThreadId); } + static mozilla::MarkerSchema MarkerTypeDisplay() { + return mozilla::MarkerSchema::SpecialFrontendLocation{}; + } }; struct IPCMarkerPayload { @@ -394,6 +471,9 @@ struct IPCMarkerPayload { aWriter.StringProperty("phase", IPCPhaseToString(aPhase)); aWriter.BoolProperty("sync", aSync); } + static mozilla::MarkerSchema MarkerTypeDisplay() { + return mozilla::MarkerSchema::SpecialFrontendLocation{}; + } private: static mozilla::Span IPCSideToString(mozilla::ipc::Side aSide) {