Bug 1444296 part 2 - Have a separate marker for styles to present stats. r=mstange

MozReview-Commit-ID: FXYnFXDvajw

--HG--
extra : rebase_source : e6b10e1df7d1815afb704b4e6eea812c2affa7fb
extra : source : 1e8a29eb9c2966f458d8019feb9f91323dc4d94a
This commit is contained in:
Xidorn Quan 2018-03-15 11:59:22 +11:00
parent 26878c7730
commit 8031c0838a
4 changed files with 95 additions and 6 deletions

View File

@ -0,0 +1,54 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_AutoProfilerStyleMarker_h
#define mozilla_AutoProfilerStyleMarker_h
#include "mozilla/Attributes.h"
#include "mozilla/ServoTraversalStatistics.h"
#include "mozilla/TimeStamp.h"
#include "GeckoProfiler.h"
#include "ProfilerMarkerPayload.h"
namespace mozilla {
class MOZ_RAII AutoProfilerStyleMarker
{
public:
explicit AutoProfilerStyleMarker(UniqueProfilerBacktrace aCause)
: mActive(profiler_is_active())
, mStartTime(TimeStamp::Now())
, mCause(Move(aCause))
{
if (!mActive) {
return;
}
MOZ_ASSERT(!ServoTraversalStatistics::sActive,
"Nested AutoProfilerStyleMarker");
ServoTraversalStatistics::sSingleton = ServoTraversalStatistics();
ServoTraversalStatistics::sActive = true;
}
~AutoProfilerStyleMarker()
{
if (!mActive) {
return;
}
ServoTraversalStatistics::sActive = false;
profiler_add_marker("Styles", MakeUnique<StyleMarkerPayload>(
mStartTime, TimeStamp::Now(), Move(mCause),
ServoTraversalStatistics::sSingleton));
}
private:
bool mActive;
TimeStamp mStartTime;
UniqueProfilerBacktrace mCause;
};
} // namespace mozilla
#endif // mozilla_AutoProfilerStyleMarker_h

View File

@ -95,6 +95,9 @@
#include "nsDisplayList.h"
#include "nsRegion.h"
#include "nsAutoLayoutPhase.h"
#ifdef MOZ_GECKO_PROFILER
#include "AutoProfilerStyleMarker.h"
#endif
#ifdef MOZ_REFLOW_PERF
#include "nsFontMetrics.h"
#endif
@ -4196,9 +4199,7 @@ PresShell::DoFlushPendingNotifications(mozilla::ChangesToFlush aFlush)
if (!mIsDestroying) {
nsAutoScriptBlocker scriptBlocker;
#ifdef MOZ_GECKO_PROFILER
AutoProfilerTracing tracingStyleFlush("Paint", "Styles",
Move(mStyleCause));
mStyleCause = nullptr;
AutoProfilerStyleMarker tracingStyleFlush(Move(mStyleCause));
#endif
mPresContext->RestyleManager()->ProcessPendingRestyles();
@ -4222,9 +4223,7 @@ PresShell::DoFlushPendingNotifications(mozilla::ChangesToFlush aFlush)
if (!mIsDestroying) {
nsAutoScriptBlocker scriptBlocker;
#ifdef MOZ_GECKO_PROFILER
AutoProfilerTracing tracingStyleFlush("Paint", "Styles",
Move(mStyleCause));
mStyleCause = nullptr;
AutoProfilerStyleMarker tracingStyleFlush(Move(mStyleCause));
#endif
mPresContext->RestyleManager()->ProcessPendingRestyles();

View File

@ -177,3 +177,17 @@ HangMarkerPayload::StreamPayload(SpliceableJSONWriter& aWriter,
{
StreamCommonProps("BHR-detected hang", aWriter, aProcessStartTime, aUniqueStacks);
}
void
StyleMarkerPayload::StreamPayload(SpliceableJSONWriter& aWriter,
const TimeStamp& aProcessStartTime,
UniqueStacks& aUniqueStacks)
{
StreamCommonProps("Styles", aWriter, aProcessStartTime, aUniqueStacks);
aWriter.StringProperty("category", "Paint");
aWriter.IntProperty("elementsTraversed", mStats.mElementsTraversed);
aWriter.IntProperty("elementsStyled", mStats.mElementsStyled);
aWriter.IntProperty("elementsMatched", mStats.mElementsMatched);
aWriter.IntProperty("stylesShared", mStats.mStylesShared);
aWriter.IntProperty("stylesReused", mStats.mStylesReused);
}

View File

@ -18,6 +18,7 @@
#include "js/Utility.h"
#include "gfxASurface.h"
#include "mozilla/ServoTraversalStatistics.h"
namespace mozilla {
namespace layers {
@ -269,4 +270,25 @@ public:
private:
};
class StyleMarkerPayload : public ProfilerMarkerPayload
{
public:
StyleMarkerPayload(const mozilla::TimeStamp& aStartTime,
const mozilla::TimeStamp& aEndTime,
UniqueProfilerBacktrace aCause,
const mozilla::ServoTraversalStatistics& aStats)
: ProfilerMarkerPayload(aStartTime, aEndTime)
, mStats(aStats)
{
if (aCause) {
SetStack(Move(aCause));
}
}
DECL_STREAM_PAYLOAD
private:
mozilla::ServoTraversalStatistics mStats;
};
#endif // ProfilerMarkerPayload_h