зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1732161 - Add profiler marker for core part of CC r=smaug,gerald
Differential Revision: https://phabricator.services.mozilla.com/D126394
This commit is contained in:
Родитель
b12f82a49c
Коммит
8b5a746c24
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "mozilla/StaticPrefs_javascript.h"
|
||||
#include "mozilla/CycleCollectedJSRuntime.h"
|
||||
#include "mozilla/ProfilerMarkers.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
#include "nsRefreshDriver.h"
|
||||
|
||||
|
@ -49,6 +50,52 @@ void CCGCScheduler::NoteGCEnd() {
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef MOZ_GECKO_PROFILER
|
||||
struct CCIntervalMarker {
|
||||
static constexpr mozilla::Span<const char> MarkerTypeName() {
|
||||
return mozilla::MakeStringSpan("CC");
|
||||
}
|
||||
static void StreamJSONMarkerData(
|
||||
baseprofiler::SpliceableJSONWriter& aWriter) {}
|
||||
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.");
|
||||
return schema;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
void CCGCScheduler::NoteCCBegin(TimeStamp aWhen) {
|
||||
#ifdef MOZ_GECKO_PROFILER
|
||||
profiler_add_marker("CC", baseprofiler::category::GCCC,
|
||||
MarkerOptions(MarkerTiming::IntervalStart(aWhen)),
|
||||
CCIntervalMarker{});
|
||||
#endif
|
||||
mIsCollectingCycles = true;
|
||||
}
|
||||
|
||||
void CCGCScheduler::NoteCCEnd(TimeStamp aWhen) {
|
||||
#ifdef MOZ_GECKO_PROFILER
|
||||
profiler_add_marker("CC", baseprofiler::category::GCCC,
|
||||
MarkerOptions(MarkerTiming::IntervalEnd(aWhen)),
|
||||
CCIntervalMarker{});
|
||||
#endif
|
||||
|
||||
mIsCollectingCycles = false;
|
||||
mLastCCEndTime = aWhen;
|
||||
mNeedsFullCC = false;
|
||||
|
||||
// The GC for this CC has already been requested.
|
||||
mNeedsGCAfterCC = false;
|
||||
}
|
||||
|
||||
void CCGCScheduler::NoteWontGC() {
|
||||
mReadyForMajorGC = false;
|
||||
mMajorGCReason = JS::GCReason::NO_REASON;
|
||||
|
|
|
@ -203,6 +203,16 @@ class CCGCScheduler {
|
|||
// A timer fired, but then decided not to run a GC.
|
||||
void NoteWontGC();
|
||||
|
||||
// This is invoked when we reach the actual cycle collection portion of the
|
||||
// overall cycle collection.
|
||||
void NoteCCBegin(TimeStamp aWhen);
|
||||
|
||||
// This is invoked when the whole process of collection is done -- i.e., CC
|
||||
// preparation (eg ForgetSkippables) in addition to the CC itself. There
|
||||
// really ought to be a separate name for the overall CC as opposed to the
|
||||
// actual cycle collection portion.
|
||||
void NoteCCEnd(TimeStamp aWhen);
|
||||
|
||||
void NoteGCSliceEnd(TimeDuration aSliceDuration) {
|
||||
if (mMajorGCReason == JS::GCReason::NO_REASON) {
|
||||
// Internally-triggered GCs do not wait for the parent's permission to
|
||||
|
@ -261,17 +271,8 @@ class CCGCScheduler {
|
|||
mCCollectedZonesWaitingForGC += aResults.mFreedJSZones;
|
||||
}
|
||||
|
||||
// This is invoked when the whole process of collection is done -- i.e., CC
|
||||
// preparation (eg ForgetSkippables), the CC itself, and the optional
|
||||
// followup GC. There really ought to be a separate name for the overall CC
|
||||
// as opposed to the actual cycle collection portion.
|
||||
void NoteCCEnd(TimeStamp aWhen) {
|
||||
mLastCCEndTime = aWhen;
|
||||
mNeedsFullCC = false;
|
||||
|
||||
// The GC for this CC has already been requested.
|
||||
mNeedsGCAfterCC = false;
|
||||
}
|
||||
// Test if we are in the NoteCCBegin .. NoteCCEnd interval.
|
||||
bool IsCollectingCycles() const { return mIsCollectingCycles; }
|
||||
|
||||
// The CC was abandoned without running a slice, so we only did forget
|
||||
// skippables. Prevent running another cycle soon.
|
||||
|
@ -432,6 +433,7 @@ class CCGCScheduler {
|
|||
JS::GCReason mMajorGCReason = JS::GCReason::NO_REASON;
|
||||
|
||||
bool mIsCompactingOnUserInactive = false;
|
||||
bool mIsCollectingCycles = false;
|
||||
bool mUserIsActive = true;
|
||||
|
||||
public:
|
||||
|
|
|
@ -1382,6 +1382,11 @@ void nsJSContext::PrepareForCycleCollectionSlice(TimeStamp aDeadline) {
|
|||
FinishAnyIncrementalGC();
|
||||
afterGCTime = TimeStamp::Now();
|
||||
}
|
||||
|
||||
if (!sScheduler.IsCollectingCycles()) {
|
||||
sScheduler.NoteCCBegin(beginTime);
|
||||
}
|
||||
|
||||
sCCStats.AfterPrepareForCycleCollectionSlice(aDeadline, beginTime,
|
||||
afterGCTime);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче