Bug 1640999 - Add `MarkerTypeDisplay` to all marker type definitions - r=gregtatum

Add `static mozilla::MarkerSchemaWriter MarkerTypeDisplay()` for each existing marker type.

Because all markers of a given type now must have the same payload and display schema, the DOM event marker has changed from type=tracing with category=DOMEvent, to its own type=DOMEvent, which is now accepted on the front-end.

Based on c9692715f2/src/profile-logic/marker-schema.js

Differential Revision: https://phabricator.services.mozilla.com/D90658
This commit is contained in:
Gerald Squelart 2020-10-14 02:11:25 +00:00
Родитель 984f996f1b
Коммит 2621d4cbf0
6 изменённых файлов: 195 добавлений и 17 удалений

Просмотреть файл

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

Просмотреть файл

@ -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<const char> 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<const char> 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

Просмотреть файл

@ -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

Просмотреть файл

@ -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<NoPayloadUserData>::Serialize(
aBuffer, aName, aCategory, std::move(aOptions));

Просмотреть файл

@ -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<const char> 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<const char> 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);

Просмотреть файл

@ -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<const char> 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<const char> 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<int64_t>(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<const char> IPCSideToString(mozilla::ipc::Side aSide) {