Bug 1675409 - Migrated ContentBuildPayload and ContentFullPaintPayload to Markers 2.0 API - r=gregtatum

In this case, the same marker type "CONTENT_FULL_PAINT_TIME" is used in separate places, so it makes sense to put the marker type definition in a common location.

Differential Revision: https://phabricator.services.mozilla.com/D96042
This commit is contained in:
Gerald Squelart 2020-11-17 22:18:58 +00:00
Родитель e456c3a5c3
Коммит 586ccbf033
4 изменённых файлов: 23 добавлений и 79 удалений

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

@ -39,7 +39,7 @@
#include "mozilla/StaticPtr.h"
#include "mozilla/Telemetry.h"
#ifdef MOZ_GECKO_PROFILER
# include "ProfilerMarkerPayload.h"
# include "mozilla/BaseProfilerMarkerTypes.h"
#endif
namespace mozilla {
@ -372,43 +372,10 @@ void ContentCompositorBridgeParent::ShadowLayersUpdated(
auto endTime = TimeStamp::Now();
#ifdef MOZ_GECKO_PROFILER
if (profiler_can_accept_markers()) {
class ContentBuildPayload : public ProfilerMarkerPayload {
public:
ContentBuildPayload(const mozilla::TimeStamp& aStartTime,
const mozilla::TimeStamp& aEndTime)
: ProfilerMarkerPayload(aStartTime, aEndTime) {}
mozilla::ProfileBufferEntryWriter::Length TagAndSerializationBytes()
const override {
return CommonPropsTagAndSerializationBytes();
}
void SerializeTagAndPayload(
mozilla::ProfileBufferEntryWriter& aEntryWriter) const override {
static const DeserializerTag tag = TagForDeserializer(Deserialize);
SerializeTagAndCommonProps(tag, aEntryWriter);
}
void StreamPayload(mozilla::baseprofiler::SpliceableJSONWriter& aWriter,
const TimeStamp& aProcessStartTime,
UniqueStacks& aUniqueStacks) const override {
StreamCommonProps("CONTENT_FULL_PAINT_TIME", aWriter, aProcessStartTime,
aUniqueStacks);
}
private:
explicit ContentBuildPayload(CommonProps&& aCommonProps)
: ProfilerMarkerPayload(std::move(aCommonProps)) {}
static mozilla::UniquePtr<ProfilerMarkerPayload> Deserialize(
mozilla::ProfileBufferEntryReader& aEntryReader) {
ProfilerMarkerPayload::CommonProps props =
DeserializeCommonProps(aEntryReader);
return UniquePtr<ProfilerMarkerPayload>(
new ContentBuildPayload(std::move(props)));
}
};
AUTO_PROFILER_STATS(add_marker_with_ContentBuildPayload);
profiler_add_marker_for_thread(
profiler_current_thread_id(), JS::ProfilingCategoryPair::GRAPHICS,
"CONTENT_FULL_PAINT_TIME",
ContentBuildPayload(aInfo.transactionStart(), endTime));
profiler_add_marker(
"CONTENT_FULL_PAINT_TIME", geckoprofiler::category::GRAPHICS,
MarkerTiming::Interval(aInfo.transactionStart(), endTime),
baseprofiler::markers::ContentBuildMarker{});
}
#endif
Telemetry::Accumulate(

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

@ -45,7 +45,7 @@
#endif
#ifdef MOZ_GECKO_PROFILER
# include "ProfilerMarkerPayload.h"
# include "mozilla/BaseProfilerMarkerTypes.h"
#endif
bool is_in_main_thread() { return NS_IsMainThread(); }
@ -226,46 +226,10 @@ class SceneBuiltNotification : public wr::NotificationHandler {
auto endTime = TimeStamp::Now();
#ifdef MOZ_GECKO_PROFILER
if (profiler_can_accept_markers()) {
class ContentFullPaintPayload : public ProfilerMarkerPayload {
public:
ContentFullPaintPayload(const mozilla::TimeStamp& aStartTime,
const mozilla::TimeStamp& aEndTime)
: ProfilerMarkerPayload(aStartTime, aEndTime) {}
mozilla::ProfileBufferEntryWriter::Length
TagAndSerializationBytes() const override {
return CommonPropsTagAndSerializationBytes();
}
void SerializeTagAndPayload(mozilla::ProfileBufferEntryWriter&
aEntryWriter) const override {
static const DeserializerTag tag =
TagForDeserializer(Deserialize);
SerializeTagAndCommonProps(tag, aEntryWriter);
}
void StreamPayload(
mozilla::baseprofiler::SpliceableJSONWriter& aWriter,
const TimeStamp& aProcessStartTime,
UniqueStacks& aUniqueStacks) const override {
StreamCommonProps("CONTENT_FULL_PAINT_TIME", aWriter,
aProcessStartTime, aUniqueStacks);
}
private:
explicit ContentFullPaintPayload(CommonProps&& aCommonProps)
: ProfilerMarkerPayload(std::move(aCommonProps)) {}
static mozilla::UniquePtr<ProfilerMarkerPayload> Deserialize(
mozilla::ProfileBufferEntryReader& aEntryReader) {
ProfilerMarkerPayload::CommonProps props =
DeserializeCommonProps(aEntryReader);
return UniquePtr<ProfilerMarkerPayload>(
new ContentFullPaintPayload(std::move(props)));
}
};
AUTO_PROFILER_STATS(add_marker_with_ContentFullPaintPayload);
profiler_add_marker_for_thread(
profiler_current_thread_id(),
JS::ProfilingCategoryPair::GRAPHICS, "CONTENT_FULL_PAINT_TIME",
ContentFullPaintPayload(startTime, endTime));
profiler_add_marker("CONTENT_FULL_PAINT_TIME",
geckoprofiler::category::GRAPHICS,
MarkerTiming::Interval(startTime, endTime),
baseprofiler::markers::ContentBuildMarker{});
}
#endif
Telemetry::Accumulate(

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

@ -132,6 +132,18 @@ struct MediaSample {
}
};
struct ContentBuildMarker {
static constexpr Span<const char> MarkerTypeName() {
return MakeStringSpan("CONTENT_FULL_PAINT_TIME");
}
static void StreamJSONMarkerData(SpliceableJSONWriter& aWriter) {}
static MarkerSchema MarkerTypeDisplay() {
using MS = MarkerSchema;
MS schema{MS::Location::markerChart, MS::Location::markerTable};
return schema;
}
};
} // namespace mozilla::baseprofiler::markers
#endif // MOZ_GECKO_PROFILER

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

@ -38,6 +38,7 @@ using Tracing = mozilla::baseprofiler::markers::Tracing;
using UserTimingMark = mozilla::baseprofiler::markers::UserTimingMark;
using UserTimingMeasure = mozilla::baseprofiler::markers::UserTimingMeasure;
using MediaSample = mozilla::baseprofiler::markers::MediaSample;
using ContentBuildMarker = mozilla::baseprofiler::markers::ContentBuildMarker;
struct ScreenshotPayload {
static constexpr mozilla::Span<const char> MarkerTypeName() {