Bug 1869835 - Part 3: Convert CC/GC markers to the new MarkerSchema so it gets full ETW support. r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D196374
This commit is contained in:
Bas Schouten 2023-12-21 18:17:41 +00:00
parent 7e993cd699
commit 020f80b429
3 changed files with 111 additions and 84 deletions

View File

@ -129,10 +129,73 @@ const TimeDuration kMaxCCLockedoutTime = TimeDuration::FromSeconds(30);
*/
namespace geckoprofiler::markers {
struct CCIntervalMarker {
static constexpr mozilla::Span<const char> MarkerTypeName() {
return mozilla::MakeStringSpan("CC");
struct CCIntervalMarker : public mozilla::BaseMarkerType<CCIntervalMarker> {
static constexpr const char* Name = "CC";
static constexpr const char* Description =
"Summary data for the core part of a cycle collection, possibly "
"encompassing a set of incremental slices. The main thread is not "
"blocked for the entire major CC interval, only for the individual "
"slices.";
using MS = mozilla::MarkerSchema;
static constexpr MS::PayloadField PayloadFields[] = {
{"mReason", MS::InputType::CString, "Reason", MS::Format::String,
MS::PayloadFlags::Searchable},
{"mMaxSliceTime", MS::InputType::TimeDuration, "Max Slice Time",
MS::Format::Duration},
{"mSuspected", MS::InputType::Uint32, "Suspected Objects",
MS::Format::Integer},
{"mSlices", MS::InputType::Uint32, "Number of Slices",
MS::Format::Integer},
{"mAnyManual", MS::InputType::Boolean, "Manually Triggered",
MS::Format::Integer},
{"mForcedGC", MS::InputType::Boolean, "GC Forced", MS::Format::Integer},
{"mMergedZones", MS::InputType::Boolean, "Zones Merged",
MS::Format::Integer},
{"mForgetSkippable", MS::InputType::Uint32, "Forget Skippables",
MS::Format::Integer},
{"mVisitedRefCounted", MS::InputType::Uint32,
"Refcounted Objects Visited", MS::Format::Integer},
{"mVisitedGCed", MS::InputType::Uint32, "GC Objects Visited",
MS::Format::Integer},
{"mFreedRefCounted", MS::InputType::Uint32, "GC Objects Freed",
MS::Format::Integer},
{"mFreedGCed", MS::InputType::Uint32, "GC Objects Freed",
MS::Format::Integer},
{"mFreedJSZones", MS::InputType::Uint32, "JS Zones Freed",
MS::Format::Integer},
{"mRemovedPurples", MS::InputType::Uint32,
"Objects Removed From Purple Buffer", MS::Format::Integer}};
static constexpr MS::Location Locations[] = {MS::Location::MarkerChart,
MS::Location::MarkerTable,
MS::Location::TimelineMemory};
static constexpr MS::ETWMarkerGroup Group = MS::ETWMarkerGroup::Memory;
static void TranslateMarkerInputToSchema(
void* aContext, bool aIsStart,
const mozilla::ProfilerString8View& aReason,
uint32_t aForgetSkippableBeforeCC, uint32_t aSuspectedAtCCStart,
uint32_t aRemovedPurples, const mozilla::CycleCollectorResults& aResults,
const mozilla::TimeDuration& aMaxSliceTime) {
uint32_t none = 0;
if (aIsStart) {
ETW::OutputMarkerSchema(aContext, CCIntervalMarker{}, aReason,
mozilla::TimeDuration{}, aSuspectedAtCCStart,
none, false, false, false,
aForgetSkippableBeforeCC, none, none, none, none,
none, aRemovedPurples);
} else {
ETW::OutputMarkerSchema(
aContext, CCIntervalMarker{}, mozilla::ProfilerStringView(""),
aMaxSliceTime, none, aResults.mNumSlices, aResults.mAnyManual,
aResults.mForcedGC, aResults.mMergedZones, none,
aResults.mVisitedRefCounted, aResults.mVisitedGCed,
aResults.mFreedRefCounted, aResults.mFreedGCed,
aResults.mFreedJSZones, none);
}
}
static void StreamJSONMarkerData(
mozilla::baseprofiler::SpliceableJSONWriter& aWriter, bool aIsStart,
const mozilla::ProfilerString8View& aReason,
@ -159,46 +222,6 @@ struct CCIntervalMarker {
aWriter.IntProperty("mFreedJSZones", aResults.mFreedJSZones);
}
}
static mozilla::MarkerSchema MarkerTypeDisplay() {
using MS = mozilla::MarkerSchema;
MS schema{MS::Location::MarkerChart, MS::Location::MarkerTable,
MS::Location::TimelineMemory};
schema.AddStaticLabelValue(
"Description",
"Summary data for the core part of a cycle collection, possibly "
"encompassing a set of incremental slices. The main thread is not "
"blocked for the entire major CC interval, only for the individual "
"slices.");
schema.AddKeyLabelFormatSearchable("mReason", "Reason", MS::Format::String,
MS::Searchable::Searchable);
schema.AddKeyLabelFormat("mMaxSliceTime", "Max Slice Time",
MS::Format::Duration);
schema.AddKeyLabelFormat("mSuspected", "Suspected Objects",
MS::Format::Integer);
schema.AddKeyLabelFormat("mSlices", "Number of Slices",
MS::Format::Integer);
schema.AddKeyLabelFormat("mAnyManual", "Manually Triggered",
MS::Format::Integer);
schema.AddKeyLabelFormat("mForcedGC", "GC Forced", MS::Format::Integer);
schema.AddKeyLabelFormat("mMergedZones", "Zones Merged",
MS::Format::Integer);
schema.AddKeyLabelFormat("mForgetSkippable", "Forget Skippables",
MS::Format::Integer);
schema.AddKeyLabelFormat("mVisitedRefCounted", "Refcounted Objects Visited",
MS::Format::Integer);
schema.AddKeyLabelFormat("mVisitedGCed", "GC Objects Visited",
MS::Format::Integer);
schema.AddKeyLabelFormat("mFreedRefCounted", "Refcounted Objects Freed",
MS::Format::Integer);
schema.AddKeyLabelFormat("mFreedGCed", "GC Objects Freed",
MS::Format::Integer);
schema.AddKeyLabelFormat("mCollectedGCZones", "JS Zones Freed",
MS::Format::Integer);
schema.AddKeyLabelFormat("mRemovedPurples",
"Objects Removed From Purple Buffer",
MS::Format::Integer);
return schema;
}
};
} // namespace geckoprofiler::markers

View File

@ -1110,23 +1110,28 @@ static void FinishAnyIncrementalGC() {
}
namespace geckoprofiler::markers {
class CCSliceMarker {
class CCSliceMarker : public BaseMarkerType<CCSliceMarker> {
public:
static constexpr Span<const char> MarkerTypeName() {
return mozilla::MakeStringSpan("CCSlice");
}
static constexpr const char* Name = "CCSlice";
static constexpr const char* Description =
"Information for an individual CC slice.";
using MS = MarkerSchema;
static constexpr MS::PayloadField PayloadFields[] = {
{"idle", MS::InputType::Boolean, "Idle", MS::Format::Integer}};
static constexpr MS::Location Locations[] = {MS::Location::MarkerChart,
MS::Location::MarkerTable,
MS::Location::TimelineMemory};
static constexpr const char* AllLabels =
"{marker.name} (idle={marker.data.idle})";
static constexpr MS::ETWMarkerGroup Group = MS::ETWMarkerGroup::Memory;
static void StreamJSONMarkerData(
mozilla::baseprofiler::SpliceableJSONWriter& aWriter,
bool aIsDuringIdle) {
aWriter.BoolProperty("idle", aIsDuringIdle);
}
static MarkerSchema MarkerTypeDisplay() {
using MS = MarkerSchema;
MS schema{MS::Location::MarkerChart, MS::Location::MarkerTable,
MS::Location::TimelineMemory};
schema.SetAllLabels("{marker.name} (idle={marker.data.idle})");
schema.AddKeyLabelFormat("idle", "Idle", MS::Format::Integer);
return schema;
StreamJSONMarkerDataImpl(aWriter, aIsDuringIdle);
}
};
} // namespace geckoprofiler::markers

View File

@ -1037,6 +1037,33 @@ void CycleCollectedJSRuntime::GCCallback(JSContext* aContext,
self->OnGC(aContext, aStatus, aReason);
}
struct GCMajorMarker : public BaseMarkerType<GCMajorMarker> {
static constexpr const char* Name = "GCMajor";
static constexpr const char* Description =
"Summary data for an entire major GC, encompassing a set of "
"incremental slices. The main thread is not blocked for the "
"entire major GC interval, only for the individual slices.";
using MS = MarkerSchema;
static constexpr MS::PayloadField PayloadFields[] = {
{"timings", MS::InputType::String, "GC timings"}};
static constexpr MS::Location Locations[] = {MS::Location::MarkerChart,
MS::Location::MarkerTable,
MS::Location::TimelineMemory};
static constexpr MS::ETWMarkerGroup Group = MS::ETWMarkerGroup::Memory;
static void StreamJSONMarkerData(
mozilla::baseprofiler::SpliceableJSONWriter& aWriter,
const mozilla::ProfilerString8View& aTimingJSON) {
if (aTimingJSON.Length() != 0) {
aWriter.SplicedJSONProperty("timings", aTimingJSON);
} else {
aWriter.NullProperty("timings");
}
}
};
/* static */
void CycleCollectedJSRuntime::GCSliceCallback(JSContext* aContext,
JS::GCProgress aProgress,
@ -1046,34 +1073,6 @@ void CycleCollectedJSRuntime::GCSliceCallback(JSContext* aContext,
if (profiler_thread_is_being_profiled_for_markers()) {
if (aProgress == JS::GC_CYCLE_END) {
struct GCMajorMarker {
static constexpr mozilla::Span<const char> MarkerTypeName() {
return mozilla::MakeStringSpan("GCMajor");
}
static void StreamJSONMarkerData(
mozilla::baseprofiler::SpliceableJSONWriter& aWriter,
const mozilla::ProfilerString8View& aTimingJSON) {
if (aTimingJSON.Length() != 0) {
aWriter.SplicedJSONProperty("timings", aTimingJSON);
} else {
aWriter.NullProperty("timings");
}
}
static mozilla::MarkerSchema MarkerTypeDisplay() {
using MS = mozilla::MarkerSchema;
MS schema{MS::Location::MarkerChart, MS::Location::MarkerTable,
MS::Location::TimelineMemory};
schema.AddStaticLabelValue(
"Description",
"Summary data for an entire major GC, encompassing a set of "
"incremental slices. The main thread is not blocked for the "
"entire major GC interval, only for the individual slices.");
// No display instructions here, there is special handling in the
// front-end.
return schema;
}
};
profiler_add_marker("GCMajor", baseprofiler::category::GCCC,
MarkerTiming::Interval(aDesc.startTime(aContext),
aDesc.endTime(aContext)),