Bug 1675409 - Migrated HangMarkerPayload to Markers 2.0 API - r=gregtatum

Differential Revision: https://phabricator.services.mozilla.com/D96036
This commit is contained in:
Gerald Squelart 2020-11-17 22:15:10 +00:00
Родитель 5e6c496f92
Коммит 986eaf5787
5 изменённых файлов: 20 добавлений и 50 удалений

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

@ -111,19 +111,6 @@ struct UserTimingMeasure {
} }
}; };
struct Hang {
static constexpr Span<const char> MarkerTypeName() {
return MakeStringSpan("BHR-detected hang");
}
static void StreamJSONMarkerData(SpliceableJSONWriter& aWriter) {}
static MarkerSchema MarkerTypeDisplay() {
using MS = MarkerSchema;
MS schema{MS::Location::markerChart, MS::Location::markerTable,
MS::Location::timelineOverview};
return schema;
}
};
struct LongTask { struct LongTask {
static constexpr Span<const char> MarkerTypeName() { static constexpr Span<const char> MarkerTypeName() {
return MakeStringSpan("MainThreadLongTask"); return MakeStringSpan("MainThreadLongTask");

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

@ -3448,10 +3448,6 @@ void TestProfiler() {
mozilla::baseprofiler::markers::UserTimingMeasure{}, "measure name", mozilla::baseprofiler::markers::UserTimingMeasure{}, "measure name",
Some(ProfilerString8View("start")), Some(ProfilerString8View("end")))); Some(ProfilerString8View("start")), Some(ProfilerString8View("end"))));
MOZ_RELEASE_ASSERT(
baseprofiler::AddMarker("hang", mozilla::baseprofiler::category::OTHER,
{}, mozilla::baseprofiler::markers::Hang{}));
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker( MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
"longtask", mozilla::baseprofiler::category::OTHER, {}, "longtask", mozilla::baseprofiler::category::OTHER, {},
mozilla::baseprofiler::markers::LongTask{})); mozilla::baseprofiler::markers::LongTask{}));
@ -3526,8 +3522,6 @@ void TestProfiler() {
svnpos); svnpos);
MOZ_RELEASE_ASSERT(profileSV.find("\"name\": \"UserTimingMeasure\",") != MOZ_RELEASE_ASSERT(profileSV.find("\"name\": \"UserTimingMeasure\",") !=
svnpos); svnpos);
MOZ_RELEASE_ASSERT(profileSV.find("\"name\": \"BHR-detected hang\",") !=
svnpos);
MOZ_RELEASE_ASSERT(profileSV.find("\"name\": \"Log\",") != svnpos); MOZ_RELEASE_ASSERT(profileSV.find("\"name\": \"Log\",") != svnpos);
MOZ_RELEASE_ASSERT(profileSV.find("\"name\": \"MediaSample\",") != svnpos); MOZ_RELEASE_ASSERT(profileSV.find("\"name\": \"MediaSample\",") != svnpos);
MOZ_RELEASE_ASSERT(profileSV.find("\"name\": \"MainThreadLongTask\",") != MOZ_RELEASE_ASSERT(profileSV.find("\"name\": \"MainThreadLongTask\",") !=
@ -4045,10 +4039,6 @@ void TestPredefinedMarkers() {
mozilla::Some(mozilla::ProfilerString8View(" start ")), mozilla::Some(mozilla::ProfilerString8View(" start ")),
mozilla::Some(mozilla::ProfilerString8View("end")))); mozilla::Some(mozilla::ProfilerString8View("end"))));
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer(
buffer, std::string_view("hang"), mozilla::baseprofiler::category::OTHER,
{}, mozilla::baseprofiler::markers::Hang{}));
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer( MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer(
buffer, std::string_view("long task"), buffer, std::string_view("long task"),
mozilla::baseprofiler::category::OTHER, {}, mozilla::baseprofiler::category::OTHER, {},

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

@ -31,10 +31,6 @@
#include "prinrval.h" #include "prinrval.h"
#include "prthread.h" #include "prthread.h"
#ifdef MOZ_GECKO_PROFILER
# include "ProfilerMarkerPayload.h"
#endif
#include <algorithm> #include <algorithm>
// Activate BHR only for one every BHR_BETA_MOD users. // Activate BHR only for one every BHR_BETA_MOD users.
@ -534,12 +530,26 @@ void BackgroundHangThread::ReportHang(TimeDuration aHangTime,
// If the profiler is enabled, add a marker. // If the profiler is enabled, add a marker.
#ifdef MOZ_GECKO_PROFILER #ifdef MOZ_GECKO_PROFILER
if (profiler_can_accept_markers()) { if (profiler_can_accept_markers()) {
TimeStamp endTime = TimeStamp::Now(); struct HangMarker {
TimeStamp startTime = endTime - aHangTime; static constexpr Span<const char> MarkerTypeName() {
AUTO_PROFILER_STATS(add_marker_with_HangMarkerPayload); return MakeStringSpan("BHR-detected hang");
profiler_add_marker_for_thread( }
mStackHelper.GetThreadId(), JS::ProfilingCategoryPair::OTHER, static void StreamJSONMarkerData(
"BHR-detected hang", HangMarkerPayload(startTime, endTime)); baseprofiler::SpliceableJSONWriter& aWriter) {}
static MarkerSchema MarkerTypeDisplay() {
using MS = MarkerSchema;
MS schema{MS::Location::markerChart, MS::Location::markerTable,
MS::Location::timelineOverview};
return schema;
}
};
const TimeStamp endTime = TimeStamp::NowUnfuzzed();
const TimeStamp startTime = endTime - aHangTime;
profiler_add_marker("BHR-detected hang", geckoprofiler::category::OTHER,
{MarkerThreadId(mStackHelper.GetThreadId()),
MarkerTiming::Interval(startTime, endTime)},
HangMarker{});
} }
#endif #endif
} }

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

@ -38,7 +38,6 @@ namespace geckoprofiler::markers {
using Tracing = mozilla::baseprofiler::markers::Tracing; using Tracing = mozilla::baseprofiler::markers::Tracing;
using UserTimingMark = mozilla::baseprofiler::markers::UserTimingMark; using UserTimingMark = mozilla::baseprofiler::markers::UserTimingMark;
using UserTimingMeasure = mozilla::baseprofiler::markers::UserTimingMeasure; using UserTimingMeasure = mozilla::baseprofiler::markers::UserTimingMeasure;
using Hang = mozilla::baseprofiler::markers::Hang;
using LongTask = mozilla::baseprofiler::markers::LongTask; using LongTask = mozilla::baseprofiler::markers::LongTask;
using Log = mozilla::baseprofiler::markers::Log; using Log = mozilla::baseprofiler::markers::Log;
using MediaSample = mozilla::baseprofiler::markers::MediaSample; using MediaSample = mozilla::baseprofiler::markers::MediaSample;

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

@ -799,9 +799,6 @@ TEST(GeckoProfiler, Markers)
(ts1, ts2, JS::UniqueChars(buffer))); (ts1, ts2, JS::UniqueChars(buffer)));
} }
PROFILER_ADD_MARKER_WITH_PAYLOAD("HangMarkerPayload marker", OTHER,
HangMarkerPayload, (ts1, ts2));
PROFILER_ADD_MARKER_WITH_PAYLOAD("LogMarkerPayload marker", OTHER, PROFILER_ADD_MARKER_WITH_PAYLOAD("LogMarkerPayload marker", OTHER,
LogMarkerPayload, ("module", "text", ts1)); LogMarkerPayload, ("module", "text", ts1));
@ -910,9 +907,6 @@ TEST(GeckoProfiler, Markers)
Some(mozilla::ProfilerString8View("start")), Some(mozilla::ProfilerString8View("start")),
Some(mozilla::ProfilerString8View("end")))); Some(mozilla::ProfilerString8View("end"))));
MOZ_RELEASE_ASSERT(profiler_add_marker("Hang", geckoprofiler::category::OTHER,
{}, geckoprofiler::markers::Hang{}));
MOZ_RELEASE_ASSERT(profiler_add_marker("LongTask", MOZ_RELEASE_ASSERT(profiler_add_marker("LongTask",
geckoprofiler::category::OTHER, {}, geckoprofiler::category::OTHER, {},
geckoprofiler::markers::LongTask{})); geckoprofiler::markers::LongTask{}));
@ -975,7 +969,6 @@ TEST(GeckoProfiler, Markers)
S_GCMajorMarkerPayload, S_GCMajorMarkerPayload,
S_GCMinorMarkerPayload, S_GCMinorMarkerPayload,
S_GCSliceMarkerPayload, S_GCSliceMarkerPayload,
S_HangMarkerPayload,
S_LogMarkerPayload, S_LogMarkerPayload,
S_LongTaskMarkerPayload, S_LongTaskMarkerPayload,
S_NativeAllocationMarkerPayload, S_NativeAllocationMarkerPayload,
@ -1350,13 +1343,6 @@ TEST(GeckoProfiler, Markers)
EXPECT_TRUE(payload["stack"].isNull()); EXPECT_TRUE(payload["stack"].isNull());
EXPECT_EQ_JSON(payload["timings"], Int, 44); EXPECT_EQ_JSON(payload["timings"], Int, 44);
} else if (nameString == "HangMarkerPayload marker") {
EXPECT_EQ(state, S_HangMarkerPayload);
state = State(S_HangMarkerPayload + 1);
EXPECT_EQ(typeString, "BHR-detected hang");
EXPECT_TIMING_INTERVAL_AT(ts1Double, ts2Double);
EXPECT_TRUE(payload["stack"].isNull());
} else if (nameString == "LogMarkerPayload marker") { } else if (nameString == "LogMarkerPayload marker") {
EXPECT_EQ(state, S_LogMarkerPayload); EXPECT_EQ(state, S_LogMarkerPayload);
state = State(S_LogMarkerPayload + 1); state = State(S_LogMarkerPayload + 1);
@ -1745,8 +1731,6 @@ TEST(GeckoProfiler, Markers)
testedSchemaNames.end()); testedSchemaNames.end());
EXPECT_TRUE(testedSchemaNames.find("UserTimingMeasure") != EXPECT_TRUE(testedSchemaNames.find("UserTimingMeasure") !=
testedSchemaNames.end()); testedSchemaNames.end());
EXPECT_TRUE(testedSchemaNames.find("BHR-detected hang") !=
testedSchemaNames.end());
EXPECT_TRUE(testedSchemaNames.find("MainThreadLongTask") != EXPECT_TRUE(testedSchemaNames.find("MainThreadLongTask") !=
testedSchemaNames.end()); testedSchemaNames.end());
EXPECT_TRUE(testedSchemaNames.find("Log") != testedSchemaNames.end()); EXPECT_TRUE(testedSchemaNames.find("Log") != testedSchemaNames.end());