Bug 1417976 - Part 2: Include DocShell IDs to marker payloads r=mstange

MozReview-Commit-ID: AML1ESUnFlu

Depends on D4914

Differential Revision: https://phabricator.services.mozilla.com/D4915

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nazım Can Altınova 2018-11-02 16:17:54 +00:00
parent 95f5ae9b3a
commit 8432e48060
14 changed files with 269 additions and 68 deletions

View File

@ -13740,6 +13740,17 @@ nsDocShell::SetOriginAttributes(JS::Handle<JS::Value> aOriginAttributes,
return SetOriginAttributes(attrs); return SetOriginAttributes(attrs);
} }
NS_IMETHODIMP
nsDocShell::GetOSHEId(uint32_t* aSHEntryId)
{
if (mOSHE) {
mOSHE->GetID(aSHEntryId);
return NS_OK;
} else {
return NS_ERROR_FAILURE;
}
}
NS_IMETHODIMP NS_IMETHODIMP
nsDocShell::GetAsyncPanZoomEnabled(bool* aOut) nsDocShell::GetAsyncPanZoomEnabled(bool* aOut)
{ {

View File

@ -1091,6 +1091,8 @@ interface nsIDocShell : nsIDocShellTreeItem
in string asyncCause); in string asyncCause);
[noscript,notxpcom,nostdcall] void notifyJSRunToCompletionStop(); [noscript,notxpcom,nostdcall] void notifyJSRunToCompletionStop();
[noscript] void GetOSHEId(out uint32_t aSHEntryId);
/** /**
* This attribute determines whether a document which is not about:blank has * This attribute determines whether a document which is not about:blank has
* already be loaded by this docShell. * already be loaded by this docShell.

View File

@ -102,14 +102,16 @@ void
nsDOMNavigationTiming::NotifyUnloadEventStart() nsDOMNavigationTiming::NotifyUnloadEventStart()
{ {
mUnloadStart = TimeStamp::Now(); mUnloadStart = TimeStamp::Now();
PROFILER_TRACING("Navigation", "Unload", TRACING_INTERVAL_START); PROFILER_TRACING_DOCSHELL(
"Navigation", "Unload", TRACING_INTERVAL_START, mDocShell);
} }
void void
nsDOMNavigationTiming::NotifyUnloadEventEnd() nsDOMNavigationTiming::NotifyUnloadEventEnd()
{ {
mUnloadEnd = TimeStamp::Now(); mUnloadEnd = TimeStamp::Now();
PROFILER_TRACING("Navigation", "Unload", TRACING_INTERVAL_END); PROFILER_TRACING_DOCSHELL(
"Navigation", "Unload", TRACING_INTERVAL_END, mDocShell);
} }
void void
@ -120,7 +122,8 @@ nsDOMNavigationTiming::NotifyLoadEventStart()
} }
mLoadEventStart = TimeStamp::Now(); mLoadEventStart = TimeStamp::Now();
PROFILER_TRACING("Navigation", "Load", TRACING_INTERVAL_START); PROFILER_TRACING_DOCSHELL(
"Navigation", "Load", TRACING_INTERVAL_START, mDocShell);
if (IsTopLevelContentDocumentInContentProcess()) { if (IsTopLevelContentDocumentInContentProcess()) {
TimeStamp now = TimeStamp::Now(); TimeStamp now = TimeStamp::Now();
@ -151,7 +154,8 @@ nsDOMNavigationTiming::NotifyLoadEventEnd()
} }
mLoadEventEnd = TimeStamp::Now(); mLoadEventEnd = TimeStamp::Now();
PROFILER_TRACING("Navigation", "Load", TRACING_INTERVAL_END); PROFILER_TRACING_DOCSHELL(
"Navigation", "Load", TRACING_INTERVAL_END, mDocShell);
if (IsTopLevelContentDocumentInContentProcess()) { if (IsTopLevelContentDocumentInContentProcess()) {
Telemetry::AccumulateTimeDelta(Telemetry::TIME_TO_LOAD_EVENT_END_MS, Telemetry::AccumulateTimeDelta(Telemetry::TIME_TO_LOAD_EVENT_END_MS,
@ -215,7 +219,8 @@ nsDOMNavigationTiming::NotifyDOMContentLoadedStart(nsIURI* aURI)
mLoadedURI = aURI; mLoadedURI = aURI;
mDOMContentLoadedEventStart = TimeStamp::Now(); mDOMContentLoadedEventStart = TimeStamp::Now();
PROFILER_TRACING("Navigation", "DOMContentLoaded", TRACING_INTERVAL_START); PROFILER_TRACING_DOCSHELL(
"Navigation", "DOMContentLoaded", TRACING_INTERVAL_START, mDocShell);
if (IsTopLevelContentDocumentInContentProcess()) { if (IsTopLevelContentDocumentInContentProcess()) {
TimeStamp now = TimeStamp::Now(); TimeStamp now = TimeStamp::Now();
@ -248,7 +253,8 @@ nsDOMNavigationTiming::NotifyDOMContentLoadedEnd(nsIURI* aURI)
mLoadedURI = aURI; mLoadedURI = aURI;
mDOMContentLoadedEventEnd = TimeStamp::Now(); mDOMContentLoadedEventEnd = TimeStamp::Now();
PROFILER_TRACING("Navigation", "DOMContentLoaded", TRACING_INTERVAL_END); PROFILER_TRACING_DOCSHELL(
"Navigation", "DOMContentLoaded", TRACING_INTERVAL_END, mDocShell);
if (IsTopLevelContentDocumentInContentProcess()) { if (IsTopLevelContentDocumentInContentProcess()) {
Telemetry::AccumulateTimeDelta(Telemetry::TIME_TO_DOM_CONTENT_LOADED_END_MS, Telemetry::AccumulateTimeDelta(Telemetry::TIME_TO_DOM_CONTENT_LOADED_END_MS,

View File

@ -6,6 +6,7 @@
#include "nsPresContext.h" #include "nsPresContext.h"
#include "nsContentUtils.h" #include "nsContentUtils.h"
#include "nsDocShell.h"
#include "nsError.h" #include "nsError.h"
#include <new> #include <new>
#include "nsIContent.h" #include "nsIContent.h"
@ -1134,12 +1135,17 @@ EventDispatcher::Dispatch(nsISupports* aTarget,
AUTO_PROFILER_LABEL_DYNAMIC_LOSSY_NSSTRING( AUTO_PROFILER_LABEL_DYNAMIC_LOSSY_NSSTRING(
"EventDispatcher::Dispatch", OTHER, typeStr); "EventDispatcher::Dispatch", OTHER, typeStr);
nsCOMPtr<nsIDocShell> docShell;
docShell = nsContentUtils::GetDocShellForEventTarget(aEvent->mTarget);
DECLARE_DOCSHELL_AND_HISTORY_ID(docShell);
profiler_add_marker( profiler_add_marker(
"DOMEvent", "DOMEvent",
MakeUnique<DOMEventMarkerPayload>(typeStr, MakeUnique<DOMEventMarkerPayload>(typeStr,
aEvent->mTimeStamp, aEvent->mTimeStamp,
"DOMEvent", "DOMEvent",
TRACING_INTERVAL_START)); TRACING_INTERVAL_START,
docShellId,
docShellHistoryId));
EventTargetChainItem::HandleEventTargetChain(chain, postVisitor, EventTargetChainItem::HandleEventTargetChain(chain, postVisitor,
aCallback, cd); aCallback, cd);
@ -1149,7 +1155,9 @@ EventDispatcher::Dispatch(nsISupports* aTarget,
MakeUnique<DOMEventMarkerPayload>(typeStr, MakeUnique<DOMEventMarkerPayload>(typeStr,
aEvent->mTimeStamp, aEvent->mTimeStamp,
"DOMEvent", "DOMEvent",
TRACING_INTERVAL_END)); TRACING_INTERVAL_END,
docShellId,
docShellHistoryId));
} else } else
#endif #endif
{ {

View File

@ -7,6 +7,7 @@
#include "Performance.h" #include "Performance.h"
#include "GeckoProfiler.h" #include "GeckoProfiler.h"
#include "nsIDocShell.h"
#include "nsRFPService.h" #include "nsRFPService.h"
#include "PerformanceEntry.h" #include "PerformanceEntry.h"
#include "PerformanceMainThread.h" #include "PerformanceMainThread.h"
@ -249,9 +250,14 @@ Performance::Mark(const nsAString& aName, ErrorResult& aRv)
#ifdef MOZ_GECKO_PROFILER #ifdef MOZ_GECKO_PROFILER
if (profiler_is_active()) { if (profiler_is_active()) {
nsCOMPtr<EventTarget> et = do_QueryInterface(GetOwner());
nsCOMPtr<nsIDocShell> docShell =
nsContentUtils::GetDocShellForEventTarget(et);
DECLARE_DOCSHELL_AND_HISTORY_ID(docShell);
profiler_add_marker( profiler_add_marker(
"UserTiming", "UserTiming",
MakeUnique<UserTimingMarkerPayload>(aName, TimeStamp::Now())); MakeUnique<UserTimingMarkerPayload>(
aName, TimeStamp::Now(), docShellId, docShellHistoryId));
} }
#endif #endif
} }
@ -347,10 +353,18 @@ Performance::Measure(const nsAString& aName,
endMark.emplace(aEndMark.Value()); endMark.emplace(aEndMark.Value());
} }
profiler_add_marker( nsCOMPtr<EventTarget> et = do_QueryInterface(GetOwner());
"UserTiming", nsCOMPtr<nsIDocShell> docShell =
MakeUnique<UserTimingMarkerPayload>(aName, startMark, endMark, nsContentUtils::GetDocShellForEventTarget(et);
startTimeStamp, endTimeStamp)); DECLARE_DOCSHELL_AND_HISTORY_ID(docShell);
profiler_add_marker("UserTiming",
MakeUnique<UserTimingMarkerPayload>(aName,
startMark,
endMark,
startTimeStamp,
endTimeStamp,
docShellId,
docShellHistoryId));
} }
#endif #endif
} }

View File

@ -18,10 +18,14 @@ namespace mozilla {
class MOZ_RAII AutoProfilerStyleMarker class MOZ_RAII AutoProfilerStyleMarker
{ {
public: public:
explicit AutoProfilerStyleMarker(UniqueProfilerBacktrace aCause) explicit AutoProfilerStyleMarker(UniqueProfilerBacktrace aCause,
const Maybe<nsID>& aDocShellId,
const Maybe<uint32_t>& aDocShellHistoryId)
: mActive(profiler_is_active()) : mActive(profiler_is_active())
, mStartTime(TimeStamp::Now()) , mStartTime(TimeStamp::Now())
, mCause(std::move(aCause)) , mCause(std::move(aCause))
, mDocShellId(aDocShellId)
, mDocShellHistoryId(aDocShellHistoryId)
{ {
if (!mActive) { if (!mActive) {
return; return;
@ -38,15 +42,22 @@ public:
return; return;
} }
ServoTraversalStatistics::sActive = false; ServoTraversalStatistics::sActive = false;
profiler_add_marker("Styles", MakeUnique<StyleMarkerPayload>( profiler_add_marker(
mStartTime, TimeStamp::Now(), std::move(mCause), "Styles",
ServoTraversalStatistics::sSingleton)); MakeUnique<StyleMarkerPayload>(mStartTime,
TimeStamp::Now(),
std::move(mCause),
ServoTraversalStatistics::sSingleton,
mDocShellId,
mDocShellHistoryId));
} }
private: private:
bool mActive; bool mActive;
TimeStamp mStartTime; TimeStamp mStartTime;
UniqueProfilerBacktrace mCause; UniqueProfilerBacktrace mCause;
Maybe<nsID> mDocShellId;
Maybe<uint32_t> mDocShellHistoryId;
}; };
} // namespace mozilla } // namespace mozilla

View File

@ -3850,7 +3850,8 @@ PresShell::ScheduleViewManagerFlush(PaintType aType)
void void
nsIPresShell::DispatchSynthMouseMove(WidgetGUIEvent* aEvent) nsIPresShell::DispatchSynthMouseMove(WidgetGUIEvent* aEvent)
{ {
AUTO_PROFILER_TRACING("Paint", "DispatchSynthMouseMove"); AUTO_PROFILER_TRACING_DOCSHELL(
"Paint", "DispatchSynthMouseMove", mPresContext->GetDocShell());
nsEventStatus status = nsEventStatus_eIgnore; nsEventStatus status = nsEventStatus_eIgnore;
nsView* targetView = nsView::GetViewFor(aEvent->mWidget); nsView* targetView = nsView::GetViewFor(aEvent->mWidget);
if (!targetView) if (!targetView)
@ -4320,7 +4321,10 @@ PresShell::DoFlushPendingNotifications(mozilla::ChangesToFlush aFlush)
if (MOZ_LIKELY(!mIsDestroying)) { if (MOZ_LIKELY(!mIsDestroying)) {
nsAutoScriptBlocker scriptBlocker; nsAutoScriptBlocker scriptBlocker;
#ifdef MOZ_GECKO_PROFILER #ifdef MOZ_GECKO_PROFILER
AutoProfilerStyleMarker tracingStyleFlush(std::move(mStyleCause)); nsCOMPtr<nsIDocShell> docShell = mPresContext->GetDocShell();
DECLARE_DOCSHELL_AND_HISTORY_ID(docShell);
AutoProfilerStyleMarker tracingStyleFlush(
std::move(mStyleCause), docShellId, docShellHistoryId);
#endif #endif
mPresContext->RestyleManager()->ProcessPendingRestyles(); mPresContext->RestyleManager()->ProcessPendingRestyles();
@ -4343,7 +4347,10 @@ PresShell::DoFlushPendingNotifications(mozilla::ChangesToFlush aFlush)
if (MOZ_LIKELY(!mIsDestroying)) { if (MOZ_LIKELY(!mIsDestroying)) {
nsAutoScriptBlocker scriptBlocker; nsAutoScriptBlocker scriptBlocker;
#ifdef MOZ_GECKO_PROFILER #ifdef MOZ_GECKO_PROFILER
AutoProfilerStyleMarker tracingStyleFlush(std::move(mStyleCause)); nsCOMPtr<nsIDocShell> docShell = mPresContext->GetDocShell();
DECLARE_DOCSHELL_AND_HISTORY_ID(docShell);
AutoProfilerStyleMarker tracingStyleFlush(
std::move(mStyleCause), docShellId, docShellHistoryId);
#endif #endif
mPresContext->RestyleManager()->ProcessPendingRestyles(); mPresContext->RestyleManager()->ProcessPendingRestyles();
@ -8952,8 +8959,12 @@ PresShell::DoReflow(nsIFrame* target, bool aInterruptible)
} }
#ifdef MOZ_GECKO_PROFILER #ifdef MOZ_GECKO_PROFILER
AutoProfilerTracing tracingLayoutFlush("Paint", "Reflow", DECLARE_DOCSHELL_AND_HISTORY_ID(docShell);
std::move(mReflowCause)); AutoProfilerTracing tracingLayoutFlush("Paint",
"Reflow",
std::move(mReflowCause),
docShellId,
docShellHistoryId);
mReflowCause = nullptr; mReflowCause = nullptr;
#endif #endif

View File

@ -1701,7 +1701,8 @@ nsRefreshDriver::RunFrameRequestCallbacks(TimeStamp aNowTime)
mFrameRequestCallbackDocs.Clear(); mFrameRequestCallbackDocs.Clear();
if (!frameRequestCallbacks.IsEmpty()) { if (!frameRequestCallbacks.IsEmpty()) {
AUTO_PROFILER_TRACING("Paint", "Scripts"); AUTO_PROFILER_TRACING_DOCSHELL(
"Paint", "Scripts", GetDocShell(mPresContext));
for (const DocumentFrameCallbacks& docCallbacks : frameRequestCallbacks) { for (const DocumentFrameCallbacks& docCallbacks : frameRequestCallbacks) {
// XXXbz Bug 863140: GetInnerWindow can return the outer // XXXbz Bug 863140: GetInnerWindow can return the outer
// window in some cases. // window in some cases.

View File

@ -5139,7 +5139,13 @@ ScrollFrameHelper::ScrollEndEvent::Run()
void void
ScrollFrameHelper::FireScrollEvent() ScrollFrameHelper::FireScrollEvent()
{ {
AUTO_PROFILER_TRACING("Paint", "FireScrollEvent"); nsIContent* content = mOuter->GetContent();
nsPresContext* prescontext = mOuter->PresContext();
#ifdef MOZ_GECKO_PROFILER
nsCOMPtr<nsIDocShell> docShell = prescontext->GetDocShell();
AUTO_PROFILER_TRACING_DOCSHELL("Paint", "FireScrollEvent", docShell);
#endif
MOZ_ASSERT(mScrollEvent); MOZ_ASSERT(mScrollEvent);
mScrollEvent->Revoke(); mScrollEvent->Revoke();
mScrollEvent = nullptr; mScrollEvent = nullptr;
@ -5147,8 +5153,6 @@ ScrollFrameHelper::FireScrollEvent()
ActiveLayerTracker::SetCurrentScrollHandlerFrame(mOuter); ActiveLayerTracker::SetCurrentScrollHandlerFrame(mOuter);
WidgetGUIEvent event(true, eScroll, nullptr); WidgetGUIEvent event(true, eScroll, nullptr);
nsEventStatus status = nsEventStatus_eIgnore; nsEventStatus status = nsEventStatus_eIgnore;
nsIContent* content = mOuter->GetContent();
nsPresContext* prescontext = mOuter->PresContext();
// Fire viewport scroll events at the document (where they // Fire viewport scroll events at the document (where they
// will bubble to the window) // will bubble to the window)
mozilla::layers::ScrollLinkedEffectDetector detector(content->GetComposedDoc()); mozilla::layers::ScrollLinkedEffectDetector detector(content->GetComposedDoc());

View File

@ -2560,7 +2560,10 @@ nsDisplayList::BuildLayers(nsDisplayListBuilder* aBuilder,
RefPtr<ContainerLayer> root; RefPtr<ContainerLayer> root;
{ {
AUTO_PROFILER_TRACING("Paint", "LayerBuilding"); #ifdef MOZ_GECKO_PROFILER
nsCOMPtr<nsIDocShell> docShell = presContext->GetDocShell();
AUTO_PROFILER_TRACING_DOCSHELL("Paint", "LayerBuilding", docShell);
#endif
if (XRE_IsContentProcess() && gfxPrefs::AlwaysPaint()) { if (XRE_IsContentProcess() && gfxPrefs::AlwaysPaint()) {
FrameLayerBuilder::InvalidateAllLayers(aLayerManager); FrameLayerBuilder::InvalidateAllLayers(aLayerManager);

View File

@ -3825,8 +3825,11 @@ profiler_add_marker_for_thread(int aThreadId,
} }
void void
profiler_tracing(const char* aCategory, const char* aMarkerName, profiler_tracing(const char* aCategory,
TracingKind aKind) const char* aMarkerName,
TracingKind aKind,
const Maybe<nsID>& aDocShellId,
const Maybe<uint32_t>& aDocShellHistoryId)
{ {
MOZ_RELEASE_ASSERT(CorePS::Exists()); MOZ_RELEASE_ASSERT(CorePS::Exists());
@ -3837,13 +3840,18 @@ profiler_tracing(const char* aCategory, const char* aMarkerName,
return; return;
} }
auto payload = MakeUnique<TracingMarkerPayload>(aCategory, aKind); auto payload = MakeUnique<TracingMarkerPayload>(
aCategory, aKind, aDocShellId, aDocShellHistoryId);
racy_profiler_add_marker(aMarkerName, std::move(payload)); racy_profiler_add_marker(aMarkerName, std::move(payload));
} }
void void
profiler_tracing(const char* aCategory, const char* aMarkerName, profiler_tracing(const char* aCategory,
TracingKind aKind, UniqueProfilerBacktrace aCause) const char* aMarkerName,
TracingKind aKind,
UniqueProfilerBacktrace aCause,
const Maybe<nsID>& aDocShellId,
const Maybe<uint32_t>& aDocShellHistoryId)
{ {
MOZ_RELEASE_ASSERT(CorePS::Exists()); MOZ_RELEASE_ASSERT(CorePS::Exists());
@ -3854,8 +3862,8 @@ profiler_tracing(const char* aCategory, const char* aMarkerName,
return; return;
} }
auto payload = auto payload = MakeUnique<TracingMarkerPayload>(
MakeUnique<TracingMarkerPayload>(aCategory, aKind, std::move(aCause)); aCategory, aKind, aDocShellId, aDocShellHistoryId, std::move(aCause));
racy_profiler_add_marker(aMarkerName, std::move(payload)); racy_profiler_add_marker(aMarkerName, std::move(payload));
} }

View File

@ -50,8 +50,11 @@
#define PROFILER_ADD_MARKER(markerName) #define PROFILER_ADD_MARKER(markerName)
#define PROFILER_ADD_NETWORK_MARKER(uri, pri, channel, type, start, end, count, timings, redirect) #define PROFILER_ADD_NETWORK_MARKER(uri, pri, channel, type, start, end, count, timings, redirect)
#define DECLARE_DOCSHELL_AND_HISTORY_ID(docShell)
#define PROFILER_TRACING(category, markerName, kind) #define PROFILER_TRACING(category, markerName, kind)
#define PROFILER_TRACING_DOCSHELL(category, markerName, kind, docshell)
#define AUTO_PROFILER_TRACING(category, markerName) #define AUTO_PROFILER_TRACING(category, markerName)
#define AUTO_PROFILER_TRACING_DOCSHELL(category, markerName, docShell)
#else // !MOZ_GECKO_PROFILER #else // !MOZ_GECKO_PROFILER
@ -613,18 +616,55 @@ enum TracingKind {
TRACING_INTERVAL_END, TRACING_INTERVAL_END,
}; };
// Helper macro to retrieve DocShellId and DocShellHistoryId from docShell
#define DECLARE_DOCSHELL_AND_HISTORY_ID(docShell) \
mozilla::Maybe<nsID> docShellId; \
mozilla::Maybe<uint32_t> docShellHistoryId; \
if (docShell) { \
docShellId = Some(docShell->HistoryID()); \
uint32_t id; \
nsresult rv = docShell->GetOSHEId(&id); \
if (NS_SUCCEEDED(rv)) { \
docShellHistoryId = Some(id); \
} else { \
docShellHistoryId = Nothing(); \
} \
} else { \
docShellId = Nothing(); \
docShellHistoryId = Nothing(); \
}
// Adds a tracing marker to the profile. A no-op if the profiler is inactive or // Adds a tracing marker to the profile. A no-op if the profiler is inactive or
// in privacy mode. // in privacy mode.
#define PROFILER_TRACING(category, markerName, kind) \ #define PROFILER_TRACING(category, markerName, kind) \
profiler_tracing(category, markerName, kind) profiler_tracing(category, markerName, kind)
void profiler_tracing(const char* aCategory, const char* aMarkerName, #define PROFILER_TRACING_DOCSHELL(category, markerName, kind, docShell) \
TracingKind aKind); DECLARE_DOCSHELL_AND_HISTORY_ID(docShell); \
void profiler_tracing(const char* aCategory, const char* aMarkerName, profiler_tracing(category, markerName, kind, docShellId, docShellHistoryId)
TracingKind aKind, UniqueProfilerBacktrace aCause); void
profiler_tracing(
const char* aCategory,
const char* aMarkerName,
TracingKind aKind,
const mozilla::Maybe<nsID>& aDocShellId = mozilla::Nothing(),
const mozilla::Maybe<uint32_t>& aDocShellHistoryId = mozilla::Nothing());
void
profiler_tracing(
const char* aCategory,
const char* aMarkerName,
TracingKind aKind,
UniqueProfilerBacktrace aCause,
const mozilla::Maybe<nsID>& aDocShellId = mozilla::Nothing(),
const mozilla::Maybe<uint32_t>& aDocShellHistoryId = mozilla::Nothing());
// Adds a START/END pair of tracing markers. // Adds a START/END pair of tracing markers.
#define AUTO_PROFILER_TRACING(category, markerName) \ #define AUTO_PROFILER_TRACING(category, markerName) \
mozilla::AutoProfilerTracing PROFILER_RAII(category, markerName) mozilla::AutoProfilerTracing PROFILER_RAII( \
category, markerName, mozilla::Nothing(), mozilla::Nothing())
#define AUTO_PROFILER_TRACING_DOCSHELL(category, markerName, docShell) \
DECLARE_DOCSHELL_AND_HISTORY_ID(docShell); \
mozilla::AutoProfilerTracing PROFILER_RAII( \
category, markerName, docShellId, docShellHistoryId)
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// Output profiles // Output profiles
@ -808,35 +848,59 @@ public:
class MOZ_RAII AutoProfilerTracing class MOZ_RAII AutoProfilerTracing
{ {
public: public:
AutoProfilerTracing(const char* aCategory, const char* aMarkerName AutoProfilerTracing(const char* aCategory,
const char* aMarkerName,
const mozilla::Maybe<nsID>& aDocShellId,
const mozilla::Maybe<uint32_t>& aDocShellHistoryId
MOZ_GUARD_OBJECT_NOTIFIER_PARAM) MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
: mCategory(aCategory) : mCategory(aCategory)
, mMarkerName(aMarkerName) , mMarkerName(aMarkerName)
, mDocShellId(aDocShellId)
, mDocShellHistoryId(aDocShellHistoryId)
{ {
MOZ_GUARD_OBJECT_NOTIFIER_INIT; MOZ_GUARD_OBJECT_NOTIFIER_INIT;
profiler_tracing(mCategory, mMarkerName, TRACING_INTERVAL_START); profiler_tracing(mCategory,
mMarkerName,
TRACING_INTERVAL_START,
mDocShellId,
mDocShellHistoryId);
} }
AutoProfilerTracing(const char* aCategory, const char* aMarkerName, AutoProfilerTracing(const char* aCategory,
UniqueProfilerBacktrace aBacktrace const char* aMarkerName,
UniqueProfilerBacktrace aBacktrace,
const mozilla::Maybe<nsID>& aDocShellId,
const mozilla::Maybe<uint32_t>& aDocShellHistoryId
MOZ_GUARD_OBJECT_NOTIFIER_PARAM) MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
: mCategory(aCategory) : mCategory(aCategory)
, mMarkerName(aMarkerName) , mMarkerName(aMarkerName)
, mDocShellId(aDocShellId)
, mDocShellHistoryId(aDocShellHistoryId)
{ {
MOZ_GUARD_OBJECT_NOTIFIER_INIT; MOZ_GUARD_OBJECT_NOTIFIER_INIT;
profiler_tracing(mCategory, mMarkerName, TRACING_INTERVAL_START, profiler_tracing(mCategory,
std::move(aBacktrace)); mMarkerName,
TRACING_INTERVAL_START,
std::move(aBacktrace),
mDocShellId,
mDocShellHistoryId);
} }
~AutoProfilerTracing() ~AutoProfilerTracing()
{ {
profiler_tracing(mCategory, mMarkerName, TRACING_INTERVAL_END); profiler_tracing(mCategory,
mMarkerName,
TRACING_INTERVAL_END,
mDocShellId,
mDocShellHistoryId);
} }
protected: protected:
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
const char* mCategory; const char* mCategory;
const char* mMarkerName; const char* mMarkerName;
const mozilla::Maybe<nsID> mDocShellId;
const mozilla::Maybe<uint32_t> mDocShellHistoryId;
}; };
// Set MOZ_PROFILER_STARTUP* environment variables that will be inherited into // Set MOZ_PROFILER_STARTUP* environment variables that will be inherited into

View File

@ -38,16 +38,26 @@ class UniqueStacks;
class ProfilerMarkerPayload class ProfilerMarkerPayload
{ {
public: public:
explicit ProfilerMarkerPayload(UniqueProfilerBacktrace aStack = nullptr) explicit ProfilerMarkerPayload(
const mozilla::Maybe<nsID>& aDocShellId = mozilla::Nothing(),
const mozilla::Maybe<uint32_t>& aDocShellHistoryId = mozilla::Nothing(),
UniqueProfilerBacktrace aStack = nullptr)
: mStack(std::move(aStack)) : mStack(std::move(aStack))
, mDocShellId(aDocShellId)
, mDocShellHistoryId(aDocShellHistoryId)
{} {}
ProfilerMarkerPayload(const mozilla::TimeStamp& aStartTime, ProfilerMarkerPayload(
const mozilla::TimeStamp& aEndTime, const mozilla::TimeStamp& aStartTime,
UniqueProfilerBacktrace aStack = nullptr) const mozilla::TimeStamp& aEndTime,
const mozilla::Maybe<nsID>& aDocShellId = mozilla::Nothing(),
const mozilla::Maybe<uint32_t>& aDocShellHistoryId = mozilla::Nothing(),
UniqueProfilerBacktrace aStack = nullptr)
: mStartTime(aStartTime) : mStartTime(aStartTime)
, mEndTime(aEndTime) , mEndTime(aEndTime)
, mStack(std::move(aStack)) , mStack(std::move(aStack))
, mDocShellId(aDocShellId)
, mDocShellHistoryId(aDocShellHistoryId)
{} {}
virtual ~ProfilerMarkerPayload() {} virtual ~ProfilerMarkerPayload() {}
@ -70,10 +80,22 @@ protected:
mStack = std::move(aStack); mStack = std::move(aStack);
} }
void SetDocShellHistoryId(const mozilla::Maybe<uint32_t>& aDocShellHistoryId)
{
mDocShellHistoryId = aDocShellHistoryId;
}
void SetDocShellId(const mozilla::Maybe<nsID>& aDocShellId)
{
mDocShellId = aDocShellId;
}
private: private:
mozilla::TimeStamp mStartTime; mozilla::TimeStamp mStartTime;
mozilla::TimeStamp mEndTime; mozilla::TimeStamp mEndTime;
UniqueProfilerBacktrace mStack; UniqueProfilerBacktrace mStack;
mozilla::Maybe<nsID> mDocShellId;
mozilla::Maybe<uint32_t> mDocShellHistoryId;
}; };
#define DECL_STREAM_PAYLOAD \ #define DECL_STREAM_PAYLOAD \
@ -81,17 +103,24 @@ private:
const mozilla::TimeStamp& aProcessStartTime, \ const mozilla::TimeStamp& aProcessStartTime, \
UniqueStacks& aUniqueStacks) override; UniqueStacks& aUniqueStacks) override;
// TODO: Increase the coverage of tracing markers that include DocShell information
class TracingMarkerPayload : public ProfilerMarkerPayload class TracingMarkerPayload : public ProfilerMarkerPayload
{ {
public: public:
TracingMarkerPayload(const char* aCategory, TracingKind aKind, TracingMarkerPayload(
UniqueProfilerBacktrace aCause = nullptr) const char* aCategory,
TracingKind aKind,
const mozilla::Maybe<nsID>& aDocShellId = mozilla::Nothing(),
const mozilla::Maybe<uint32_t>& aDocShellHistoryId = mozilla::Nothing(),
UniqueProfilerBacktrace aCause = nullptr)
: mCategory(aCategory) : mCategory(aCategory)
, mKind(aKind) , mKind(aKind)
{ {
if (aCause) { if (aCause) {
SetStack(std::move(aCause)); SetStack(std::move(aCause));
} }
SetDocShellId(aDocShellId);
SetDocShellHistoryId(aDocShellHistoryId);
} }
DECL_STREAM_PAYLOAD DECL_STREAM_PAYLOAD
@ -104,11 +133,16 @@ private:
class IOMarkerPayload : public ProfilerMarkerPayload class IOMarkerPayload : public ProfilerMarkerPayload
{ {
public: public:
IOMarkerPayload(const char* aSource, const char* aFilename, IOMarkerPayload(const char* aSource,
const char* aFilename,
const mozilla::TimeStamp& aStartTime, const mozilla::TimeStamp& aStartTime,
const mozilla::TimeStamp& aEndTime, const mozilla::TimeStamp& aEndTime,
UniqueProfilerBacktrace aStack) UniqueProfilerBacktrace aStack)
: ProfilerMarkerPayload(aStartTime, aEndTime, std::move(aStack)) : ProfilerMarkerPayload(aStartTime,
aEndTime,
mozilla::Nothing(),
mozilla::Nothing(),
std::move(aStack))
, mSource(aSource) , mSource(aSource)
, mFilename(aFilename ? strdup(aFilename) : nullptr) , mFilename(aFilename ? strdup(aFilename) : nullptr)
{ {
@ -127,8 +161,11 @@ class DOMEventMarkerPayload : public TracingMarkerPayload
public: public:
DOMEventMarkerPayload(const nsAString& aEventType, DOMEventMarkerPayload(const nsAString& aEventType,
const mozilla::TimeStamp& aTimeStamp, const mozilla::TimeStamp& aTimeStamp,
const char* aCategory, TracingKind aKind) const char* aCategory,
: TracingMarkerPayload(aCategory, aKind) TracingKind aKind,
const mozilla::Maybe<nsID>& aDocShellId,
const mozilla::Maybe<uint32_t>& aDocShellHistoryId)
: TracingMarkerPayload(aCategory, aKind, aDocShellId, aDocShellHistoryId)
, mTimeStamp(aTimeStamp) , mTimeStamp(aTimeStamp)
, mEventType(aEventType) , mEventType(aEventType)
{} {}
@ -144,8 +181,13 @@ class UserTimingMarkerPayload : public ProfilerMarkerPayload
{ {
public: public:
UserTimingMarkerPayload(const nsAString& aName, UserTimingMarkerPayload(const nsAString& aName,
const mozilla::TimeStamp& aStartTime) const mozilla::TimeStamp& aStartTime,
: ProfilerMarkerPayload(aStartTime, aStartTime) const mozilla::Maybe<nsID>& aDocShellId,
const mozilla::Maybe<uint32_t>& aDocShellHistoryId)
: ProfilerMarkerPayload(aStartTime,
aStartTime,
aDocShellId,
aDocShellHistoryId)
, mEntryType("mark") , mEntryType("mark")
, mName(aName) , mName(aName)
{} {}
@ -154,8 +196,13 @@ public:
const mozilla::Maybe<nsString>& aStartMark, const mozilla::Maybe<nsString>& aStartMark,
const mozilla::Maybe<nsString>& aEndMark, const mozilla::Maybe<nsString>& aEndMark,
const mozilla::TimeStamp& aStartTime, const mozilla::TimeStamp& aStartTime,
const mozilla::TimeStamp& aEndTime) const mozilla::TimeStamp& aEndTime,
: ProfilerMarkerPayload(aStartTime, aEndTime) const mozilla::Maybe<nsID>& aDocShellId,
const mozilla::Maybe<uint32_t>& aDocShellHistoryId)
: ProfilerMarkerPayload(aStartTime,
aEndTime,
aDocShellId,
aDocShellHistoryId)
, mEntryType("measure") , mEntryType("measure")
, mName(aName) , mName(aName)
, mStartMark(aStartMark) , mStartMark(aStartMark)
@ -208,7 +255,8 @@ public:
class NetworkMarkerPayload : public ProfilerMarkerPayload class NetworkMarkerPayload : public ProfilerMarkerPayload
{ {
public: public:
NetworkMarkerPayload(int64_t aID, const char* aURI, NetworkMarkerPayload(int64_t aID,
const char* aURI,
NetworkLoadType aType, NetworkLoadType aType,
const mozilla::TimeStamp& aStartTime, const mozilla::TimeStamp& aStartTime,
const mozilla::TimeStamp& aEndTime, const mozilla::TimeStamp& aEndTime,
@ -216,10 +264,12 @@ public:
int64_t aCount, int64_t aCount,
const mozilla::net::TimingStruct* aTimings = nullptr, const mozilla::net::TimingStruct* aTimings = nullptr,
const char* aRedirectURI = nullptr) const char* aRedirectURI = nullptr)
: ProfilerMarkerPayload(aStartTime, aEndTime) : ProfilerMarkerPayload(aStartTime, aEndTime, mozilla::Nothing())
, mID(aID) , mID(aID)
, mURI(aURI ? strdup(aURI) : nullptr) , mURI(aURI ? strdup(aURI) : nullptr)
, mRedirectURI(aRedirectURI && (strlen(aRedirectURI) > 0) ? strdup(aRedirectURI) : nullptr) , mRedirectURI(aRedirectURI && (strlen(aRedirectURI) > 0)
? strdup(aRedirectURI)
: nullptr)
, mType(aType) , mType(aType)
, mPri(aPri) , mPri(aPri)
, mCount(aCount) , mCount(aCount)
@ -328,8 +378,13 @@ public:
StyleMarkerPayload(const mozilla::TimeStamp& aStartTime, StyleMarkerPayload(const mozilla::TimeStamp& aStartTime,
const mozilla::TimeStamp& aEndTime, const mozilla::TimeStamp& aEndTime,
UniqueProfilerBacktrace aCause, UniqueProfilerBacktrace aCause,
const mozilla::ServoTraversalStatistics& aStats) const mozilla::ServoTraversalStatistics& aStats,
: ProfilerMarkerPayload(aStartTime, aEndTime) const mozilla::Maybe<nsID>& aDocShellId,
const mozilla::Maybe<uint32_t>& aDocShellHistoryId)
: ProfilerMarkerPayload(aStartTime,
aEndTime,
aDocShellId,
aDocShellHistoryId)
, mStats(aStats) , mStats(aStats)
{ {
if (aCause) { if (aCause) {

View File

@ -458,7 +458,10 @@ TEST(GeckoProfiler, Markers)
PROFILER_ADD_MARKER("M3"); PROFILER_ADD_MARKER("M3");
profiler_add_marker( profiler_add_marker(
"M4", "M4",
MakeUnique<TracingMarkerPayload>("C", TRACING_EVENT, MakeUnique<TracingMarkerPayload>("C",
TRACING_EVENT,
mozilla::Nothing(),
mozilla::Nothing(),
profiler_get_backtrace())); profiler_get_backtrace()));
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {