mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1583271 - Part 1: Change profiler page information IDs to BrowsingContextID and InnerWindowID r=gerald,nika
We were keeping nsDocShell::mHistoryId and nsDocShell::mOSHE as keys. They weren't quite good because: 1. While loading an iframe, they were being registered twice with the same ids(for about:blank and the real URL) sometimes. 2. It wasn't possible to access to the parent mHistoryId and mOSHE from a child processes if the parent is in a different process. That may not be the case for now, but it will be after fission. So we had to find other IDs to: 1. Determine the Tab of the frames. 2. Determine the URLs of the frames. For the first use case, we were using nsDocShell::mHistoryId for that purpose but that was wrong. The closest thing that we can get to a tab ID is BrowsingContext ID because they don't change after a navigation. But iframes have different BrowsingContext's, so we still need to create a tree to construct a tab content. That can be either in the front-end or capture time. For the second use case, we were using a key pair of mHistoryId and mOSHE. We now chose to keep inner window IDs for that purpose. Inner window IDs are unique for each navigation loads because inner window correspond to each JS window global objects. That's why we can use that without any problem. But one problem is that we cannot handle `history.pushState` and `history.replaceState` changes with that change since window global objects won't change during those. But that was the best thing we can do after fission. So this will be a small sacrifice for us to keep that functionality working after fission. In that patch we also remove the registration/unregistration calls. We are going to add those calls in the next patch. Differential Revision: https://phabricator.services.mozilla.com/D47065 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
7e3b8fe633
commit
20fc64e558
@ -431,10 +431,6 @@ nsDocShell::~nsDocShell() {
|
||||
// Avoid notifying observers while we're in the dtor.
|
||||
mIsBeingDestroyed = true;
|
||||
|
||||
#ifdef MOZ_GECKO_PROFILER
|
||||
profiler_unregister_pages(mHistoryID);
|
||||
#endif
|
||||
|
||||
Destroy();
|
||||
|
||||
if (mSessionHistory) {
|
||||
@ -8259,7 +8255,7 @@ nsresult nsDocShell::CreateContentViewer(const nsACString& aContentType,
|
||||
TimeStamp now = TimeStamp::Now();
|
||||
profiler_add_text_marker("Background Iframe", marker,
|
||||
JS::ProfilingCategoryPair::DOM, now, now,
|
||||
Nothing(), Nothing());
|
||||
Nothing());
|
||||
#endif
|
||||
SetBackgroundLoadIframe();
|
||||
}
|
||||
@ -11085,22 +11081,6 @@ bool nsDocShell::OnNewURI(nsIURI* aURI, nsIChannel* aChannel,
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MOZ_GECKO_PROFILER
|
||||
// We register the page load only if the load updates the history and it's
|
||||
// not a refresh. This also registers the iframes in shift-reload case, but
|
||||
// it's reasonable to register since we are updating the historyId in that
|
||||
// case.
|
||||
if (updateSHistory) {
|
||||
uint32_t id = 0;
|
||||
nsAutoCString spec;
|
||||
if (mLSHE) {
|
||||
mLSHE->GetID(&id);
|
||||
}
|
||||
aURI->GetSpec(spec);
|
||||
profiler_register_page(mHistoryID, id, spec, IsFrame());
|
||||
}
|
||||
#endif
|
||||
|
||||
// If this is a POST request, we do not want to include this in global
|
||||
// history.
|
||||
if (updateGHistory && aAddToGlobalHistory && !ChannelIsPost(aChannel)) {
|
||||
@ -11421,14 +11401,6 @@ nsresult nsDocShell::UpdateURLAndHistory(Document* aDocument, nsIURI* aNewURI,
|
||||
// AddToSessionHistory may not modify mOSHE. In case it doesn't,
|
||||
// we'll just set mOSHE here.
|
||||
mOSHE = newSHEntry;
|
||||
|
||||
#ifdef MOZ_GECKO_PROFILER
|
||||
uint32_t id = 0;
|
||||
GetOSHEId(&id);
|
||||
profiler_register_page(mHistoryID, id, aNewURI->GetSpecOrDefault(),
|
||||
IsFrame());
|
||||
#endif
|
||||
|
||||
} else {
|
||||
// Step 3.
|
||||
newSHEntry = mOSHE;
|
||||
|
@ -163,11 +163,11 @@ void nsDOMNavigationTiming::NotifyLoadEventEnd() {
|
||||
nsPrintfCString marker(
|
||||
"Document %s loaded after %dms, load event duration %dms", spec.get(),
|
||||
int(elapsed.ToMilliseconds()), int(duration.ToMilliseconds()));
|
||||
DECLARE_DOCSHELL_AND_HISTORY_ID(mDocShell);
|
||||
PAGELOAD_LOG(("%s", marker.get()));
|
||||
PROFILER_ADD_MARKER_WITH_PAYLOAD("DocumentLoad", DOM, TextMarkerPayload,
|
||||
(marker, mNavigationStart, mLoadEventEnd,
|
||||
docShellId, docShellHistoryId));
|
||||
PROFILER_ADD_MARKER_WITH_PAYLOAD(
|
||||
"DocumentLoad", DOM, TextMarkerPayload,
|
||||
(marker, mNavigationStart, mLoadEventEnd,
|
||||
profiler_get_inner_window_id_from_docshell(mDocShell)));
|
||||
}
|
||||
#endif
|
||||
Telemetry::AccumulateTimeDelta(Telemetry::TIME_TO_LOAD_EVENT_END_MS,
|
||||
@ -358,10 +358,10 @@ void nsDOMNavigationTiming::TTITimeout(nsITimer* aTimer) {
|
||||
int(elapsed.ToMilliseconds()),
|
||||
int(elapsedLongTask.ToMilliseconds()), spec.get());
|
||||
|
||||
DECLARE_DOCSHELL_AND_HISTORY_ID(mDocShell);
|
||||
PROFILER_ADD_MARKER_WITH_PAYLOAD(
|
||||
"TTFI", DOM, TextMarkerPayload,
|
||||
(marker, mNavigationStart, mTTFI, docShellId, docShellHistoryId));
|
||||
(marker, mNavigationStart, mTTFI,
|
||||
profiler_get_inner_window_id_from_docshell(mDocShell)));
|
||||
}
|
||||
#endif
|
||||
return;
|
||||
@ -392,11 +392,10 @@ void nsDOMNavigationTiming::NotifyNonBlankPaintForRootContentDocument() {
|
||||
: "this tab was inactive some of the time between navigation start "
|
||||
"and first non-blank paint");
|
||||
PAGELOAD_LOG(("%s", marker.get()));
|
||||
DECLARE_DOCSHELL_AND_HISTORY_ID(mDocShell);
|
||||
PROFILER_ADD_MARKER_WITH_PAYLOAD("FirstNonBlankPaint", DOM,
|
||||
TextMarkerPayload,
|
||||
(marker, mNavigationStart, mNonBlankPaint,
|
||||
docShellId, docShellHistoryId));
|
||||
PROFILER_ADD_MARKER_WITH_PAYLOAD(
|
||||
"FirstNonBlankPaint", DOM, TextMarkerPayload,
|
||||
(marker, mNavigationStart, mNonBlankPaint,
|
||||
profiler_get_inner_window_id_from_docshell(mDocShell)));
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -441,12 +440,11 @@ void nsDOMNavigationTiming::NotifyContentfulPaintForRootContentDocument(
|
||||
? "foreground tab"
|
||||
: "this tab was inactive some of the time between navigation start "
|
||||
"and first non-blank paint");
|
||||
DECLARE_DOCSHELL_AND_HISTORY_ID(mDocShell);
|
||||
PAGELOAD_LOG(("%s", marker.get()));
|
||||
PROFILER_ADD_MARKER_WITH_PAYLOAD(
|
||||
"FirstContentfulPaint", DOM, TextMarkerPayload,
|
||||
(marker, mNavigationStart, mContentfulPaint, docShellId,
|
||||
docShellHistoryId));
|
||||
(marker, mNavigationStart, mContentfulPaint,
|
||||
profiler_get_inner_window_id_from_docshell(mDocShell)));
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -491,12 +489,11 @@ void nsDOMNavigationTiming::NotifyDOMContentFlushedForRootContentDocument() {
|
||||
? "foreground tab"
|
||||
: "this tab was inactive some of the time between navigation start "
|
||||
"and DOMContentFlushed");
|
||||
DECLARE_DOCSHELL_AND_HISTORY_ID(mDocShell);
|
||||
PAGELOAD_LOG(("%s", marker.get()));
|
||||
PROFILER_ADD_MARKER_WITH_PAYLOAD(
|
||||
"DOMContentFlushed", DOM, TextMarkerPayload,
|
||||
(marker, mNavigationStart, mDOMContentFlushed, docShellId,
|
||||
docShellHistoryId));
|
||||
(marker, mNavigationStart, mDOMContentFlushed,
|
||||
profiler_get_inner_window_id_from_docshell(mDocShell)));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -1026,11 +1026,15 @@ nsresult EventDispatcher::Dispatch(nsISupports* aTarget,
|
||||
|
||||
nsCOMPtr<nsIDocShell> docShell;
|
||||
docShell = nsContentUtils::GetDocShellForEventTarget(aEvent->mTarget);
|
||||
DECLARE_DOCSHELL_AND_HISTORY_ID(docShell);
|
||||
Maybe<uint64_t> innerWindowID;
|
||||
if (nsCOMPtr<nsPIDOMWindowInner> inner =
|
||||
do_QueryInterface(aEvent->mTarget->GetOwnerGlobal())) {
|
||||
innerWindowID = Some(inner->WindowID());
|
||||
}
|
||||
PROFILER_ADD_MARKER_WITH_PAYLOAD(
|
||||
"DOMEvent", DOM, DOMEventMarkerPayload,
|
||||
(typeStr, aEvent->mTimeStamp, "DOMEvent", TRACING_INTERVAL_START,
|
||||
docShellId, docShellHistoryId));
|
||||
innerWindowID));
|
||||
|
||||
EventTargetChainItem::HandleEventTargetChain(chain, postVisitor,
|
||||
aCallback, cd);
|
||||
@ -1038,7 +1042,7 @@ nsresult EventDispatcher::Dispatch(nsISupports* aTarget,
|
||||
PROFILER_ADD_MARKER_WITH_PAYLOAD(
|
||||
"DOMEvent", DOM, DOMEventMarkerPayload,
|
||||
(typeStr, aEvent->mTimeStamp, "DOMEvent", TRACING_INTERVAL_END,
|
||||
docShellId, docShellHistoryId));
|
||||
innerWindowID));
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
|
@ -222,13 +222,12 @@ void Performance::Mark(const nsAString& aName, ErrorResult& aRv) {
|
||||
|
||||
#ifdef MOZ_GECKO_PROFILER
|
||||
if (profiler_can_accept_markers()) {
|
||||
nsCOMPtr<EventTarget> et = do_QueryInterface(GetOwner());
|
||||
nsCOMPtr<nsIDocShell> docShell =
|
||||
nsContentUtils::GetDocShellForEventTarget(et);
|
||||
DECLARE_DOCSHELL_AND_HISTORY_ID(docShell);
|
||||
PROFILER_ADD_MARKER_WITH_PAYLOAD(
|
||||
"UserTiming", DOM, UserTimingMarkerPayload,
|
||||
(aName, TimeStamp::Now(), docShellId, docShellHistoryId));
|
||||
Maybe<uint64_t> innerWindowId;
|
||||
if (GetOwner()) {
|
||||
innerWindowId = Some(GetOwner()->WindowID());
|
||||
}
|
||||
PROFILER_ADD_MARKER_WITH_PAYLOAD("UserTiming", DOM, UserTimingMarkerPayload,
|
||||
(aName, TimeStamp::Now(), innerWindowId));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -326,14 +325,13 @@ void Performance::Measure(const nsAString& aName,
|
||||
endMark.emplace(aEndMark.Value());
|
||||
}
|
||||
|
||||
nsCOMPtr<EventTarget> et = do_QueryInterface(GetOwner());
|
||||
nsCOMPtr<nsIDocShell> docShell =
|
||||
nsContentUtils::GetDocShellForEventTarget(et);
|
||||
DECLARE_DOCSHELL_AND_HISTORY_ID(docShell);
|
||||
PROFILER_ADD_MARKER_WITH_PAYLOAD(
|
||||
"UserTiming", DOM, UserTimingMarkerPayload,
|
||||
(aName, startMark, endMark, startTimeStamp, endTimeStamp, docShellId,
|
||||
docShellHistoryId));
|
||||
Maybe<uint64_t> innerWindowId;
|
||||
if (GetOwner()) {
|
||||
innerWindowId = Some(GetOwner()->WindowID());
|
||||
}
|
||||
PROFILER_ADD_MARKER_WITH_PAYLOAD("UserTiming", DOM, UserTimingMarkerPayload,
|
||||
(aName, startMark, endMark, startTimeStamp,
|
||||
endTimeStamp, innerWindowId));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -18,13 +18,11 @@ namespace mozilla {
|
||||
class MOZ_RAII AutoProfilerStyleMarker {
|
||||
public:
|
||||
explicit AutoProfilerStyleMarker(UniqueProfilerBacktrace aCause,
|
||||
const Maybe<nsID>& aDocShellId,
|
||||
const Maybe<uint32_t>& aDocShellHistoryId)
|
||||
const Maybe<uint64_t>& aInnerWindowID)
|
||||
: mActive(profiler_can_accept_markers()),
|
||||
mStartTime(TimeStamp::Now()),
|
||||
mCause(std::move(aCause)),
|
||||
mDocShellId(aDocShellId),
|
||||
mDocShellHistoryId(aDocShellHistoryId) {
|
||||
mInnerWindowID(aInnerWindowID) {
|
||||
if (!mActive) {
|
||||
return;
|
||||
}
|
||||
@ -42,16 +40,14 @@ class MOZ_RAII AutoProfilerStyleMarker {
|
||||
PROFILER_ADD_MARKER_WITH_PAYLOAD(
|
||||
"Styles", LAYOUT, StyleMarkerPayload,
|
||||
(mStartTime, TimeStamp::Now(), std::move(mCause),
|
||||
ServoTraversalStatistics::sSingleton, mDocShellId,
|
||||
mDocShellHistoryId));
|
||||
ServoTraversalStatistics::sSingleton, mInnerWindowID));
|
||||
}
|
||||
|
||||
private:
|
||||
bool mActive;
|
||||
TimeStamp mStartTime;
|
||||
UniqueProfilerBacktrace mCause;
|
||||
Maybe<nsID> mDocShellId;
|
||||
Maybe<uint32_t> mDocShellHistoryId;
|
||||
Maybe<uint64_t> mInnerWindowID;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -4109,10 +4109,12 @@ void PresShell::DoFlushPendingNotifications(mozilla::ChangesToFlush aFlush) {
|
||||
if (MOZ_LIKELY(!mIsDestroying)) {
|
||||
nsAutoScriptBlocker scriptBlocker;
|
||||
#ifdef MOZ_GECKO_PROFILER
|
||||
nsCOMPtr<nsIDocShell> docShell = mPresContext->GetDocShell();
|
||||
DECLARE_DOCSHELL_AND_HISTORY_ID(docShell);
|
||||
Maybe<uint64_t> innerWindowID;
|
||||
if (auto* window = mDocument->GetInnerWindow()) {
|
||||
innerWindowID = Some(window->WindowID());
|
||||
}
|
||||
AutoProfilerStyleMarker tracingStyleFlush(std::move(mStyleCause),
|
||||
docShellId, docShellHistoryId);
|
||||
innerWindowID);
|
||||
#endif
|
||||
PerfStats::AutoMetricRecording<PerfStats::Metric::Styling> autoRecording;
|
||||
|
||||
@ -4138,10 +4140,12 @@ void PresShell::DoFlushPendingNotifications(mozilla::ChangesToFlush aFlush) {
|
||||
if (MOZ_LIKELY(!mIsDestroying)) {
|
||||
nsAutoScriptBlocker scriptBlocker;
|
||||
#ifdef MOZ_GECKO_PROFILER
|
||||
nsCOMPtr<nsIDocShell> docShell = mPresContext->GetDocShell();
|
||||
DECLARE_DOCSHELL_AND_HISTORY_ID(docShell);
|
||||
Maybe<uint64_t> innerWindowID;
|
||||
if (auto* window = mDocument->GetInnerWindow()) {
|
||||
innerWindowID = Some(window->WindowID());
|
||||
}
|
||||
AutoProfilerStyleMarker tracingStyleFlush(std::move(mStyleCause),
|
||||
docShellId, docShellHistoryId);
|
||||
innerWindowID);
|
||||
#endif
|
||||
PerfStats::AutoMetricRecording<PerfStats::Metric::Styling> autoRecording;
|
||||
|
||||
@ -9127,10 +9131,13 @@ bool PresShell::DoReflow(nsIFrame* target, bool aInterruptible,
|
||||
}
|
||||
|
||||
#ifdef MOZ_GECKO_PROFILER
|
||||
DECLARE_DOCSHELL_AND_HISTORY_ID(docShell);
|
||||
Maybe<uint64_t> innerWindowID;
|
||||
if (auto* window = mDocument->GetInnerWindow()) {
|
||||
innerWindowID = Some(window->WindowID());
|
||||
}
|
||||
AutoProfilerTracing tracingLayoutFlush(
|
||||
"Paint", "Reflow", JS::ProfilingCategoryPair::LAYOUT,
|
||||
std::move(mReflowCause), docShellId, docShellHistoryId);
|
||||
std::move(mReflowCause), innerWindowID);
|
||||
mReflowCause = nullptr;
|
||||
#endif
|
||||
|
||||
|
@ -15,25 +15,29 @@
|
||||
namespace mozilla {
|
||||
namespace baseprofiler {
|
||||
|
||||
PageInformation::PageInformation(const std::string& aDocShellId,
|
||||
uint32_t aDocShellHistoryId,
|
||||
PageInformation::PageInformation(uint64_t aBrowsingContextID,
|
||||
uint64_t aInnerWindowID,
|
||||
const std::string& aUrl, bool aIsSubFrame)
|
||||
: mDocShellId(aDocShellId),
|
||||
mDocShellHistoryId(aDocShellHistoryId),
|
||||
: mBrowsingContextID(aBrowsingContextID),
|
||||
mInnerWindowID(aInnerWindowID),
|
||||
mUrl(aUrl),
|
||||
mIsSubFrame(aIsSubFrame),
|
||||
mRefCnt(0) {}
|
||||
|
||||
bool PageInformation::Equals(PageInformation* aOtherPageInfo) {
|
||||
return DocShellHistoryId() == aOtherPageInfo->DocShellHistoryId() &&
|
||||
DocShellId() == aOtherPageInfo->DocShellId() &&
|
||||
IsSubFrame() == aOtherPageInfo->IsSubFrame();
|
||||
bool PageInformation::Equals(PageInformation* aOtherPageInfo) const {
|
||||
// It's enough to check inner window IDs because they are unique for each
|
||||
// page. Therefore, we don't have to check browsing context ID or url.
|
||||
return InnerWindowID() == aOtherPageInfo->InnerWindowID();
|
||||
}
|
||||
|
||||
void PageInformation::StreamJSON(SpliceableJSONWriter& aWriter) {
|
||||
void PageInformation::StreamJSON(SpliceableJSONWriter& aWriter) const {
|
||||
aWriter.StartObjectElement();
|
||||
aWriter.StringProperty("docshellId", DocShellId().c_str());
|
||||
aWriter.DoubleProperty("historyId", DocShellHistoryId());
|
||||
// Here, we are converting uint64_t to double. Both Browsing Context and Inner
|
||||
// Window IDs are creating using `nsContentUtils::GenerateProcessSpecificId`,
|
||||
// which is specifically designed to only use 53 of the 64 bits to be lossless
|
||||
// when passed into and out of JS as a double.
|
||||
aWriter.DoubleProperty("browsingContextID", BrowsingContextID());
|
||||
aWriter.DoubleProperty("innerWindowID", InnerWindowID());
|
||||
aWriter.StringProperty("url", Url().c_str());
|
||||
aWriter.BoolProperty("isSubFrame", IsSubFrame());
|
||||
aWriter.EndObject();
|
||||
|
@ -27,7 +27,7 @@ class SpliceableJSONWriter;
|
||||
// it in the next page registration.
|
||||
class PageInformation final {
|
||||
public:
|
||||
PageInformation(const std::string& aDocShellId, uint32_t aDocShellHistoryId,
|
||||
PageInformation(uint64_t aBrowsingContextID, uint64_t aInnerWindowID,
|
||||
const std::string& aUrl, bool aIsSubFrame);
|
||||
|
||||
// Using hand-rolled ref-counting, because RefCounted.h macros don't produce
|
||||
@ -41,15 +41,15 @@ class PageInformation final {
|
||||
}
|
||||
|
||||
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const;
|
||||
bool Equals(PageInformation* aOtherDocShellInfo);
|
||||
void StreamJSON(SpliceableJSONWriter& aWriter);
|
||||
bool Equals(PageInformation* aOtherPageInfo) const;
|
||||
void StreamJSON(SpliceableJSONWriter& aWriter) const;
|
||||
|
||||
uint32_t DocShellHistoryId() { return mDocShellHistoryId; }
|
||||
const std::string& DocShellId() { return mDocShellId; }
|
||||
const std::string& Url() { return mUrl; }
|
||||
bool IsSubFrame() { return mIsSubFrame; }
|
||||
uint64_t InnerWindowID() const { return mInnerWindowID; }
|
||||
uint64_t BrowsingContextID() const { return mBrowsingContextID; }
|
||||
const std::string& Url() const { return mUrl; }
|
||||
bool IsSubFrame() const { return mIsSubFrame; }
|
||||
|
||||
Maybe<uint64_t> BufferPositionWhenUnregistered() {
|
||||
Maybe<uint64_t> BufferPositionWhenUnregistered() const {
|
||||
return mBufferPositionWhenUnregistered;
|
||||
}
|
||||
|
||||
@ -58,13 +58,13 @@ class PageInformation final {
|
||||
}
|
||||
|
||||
private:
|
||||
const std::string mDocShellId;
|
||||
const uint32_t mDocShellHistoryId;
|
||||
const uint64_t mBrowsingContextID;
|
||||
const uint64_t mInnerWindowID;
|
||||
const std::string mUrl;
|
||||
const bool mIsSubFrame;
|
||||
|
||||
// Holds the buffer position when DocShell is unregistered.
|
||||
// It's used to determine if we still use this DocShell in the profiler or
|
||||
// Holds the buffer position when page is unregistered.
|
||||
// It's used to determine if we still use this page in the profiler or
|
||||
// not.
|
||||
Maybe<uint64_t> mBufferPositionWhenUnregistered;
|
||||
|
||||
|
@ -112,8 +112,7 @@ ProfilerMarkerPayload::CommonPropsTagAndSerializationBytes() const {
|
||||
return sizeof(DeserializerTag) +
|
||||
BlocksRingBuffer::SumBytes(mCommonProps.mStartTime,
|
||||
mCommonProps.mEndTime, mCommonProps.mStack,
|
||||
mCommonProps.mDocShellId,
|
||||
mCommonProps.mDocShellHistoryId);
|
||||
mCommonProps.mInnerWindowID);
|
||||
}
|
||||
|
||||
void ProfilerMarkerPayload::SerializeTagAndCommonProps(
|
||||
@ -123,8 +122,7 @@ void ProfilerMarkerPayload::SerializeTagAndCommonProps(
|
||||
aEntryWriter.WriteObject(mCommonProps.mStartTime);
|
||||
aEntryWriter.WriteObject(mCommonProps.mEndTime);
|
||||
aEntryWriter.WriteObject(mCommonProps.mStack);
|
||||
aEntryWriter.WriteObject(mCommonProps.mDocShellId);
|
||||
aEntryWriter.WriteObject(mCommonProps.mDocShellHistoryId);
|
||||
aEntryWriter.WriteObject(mCommonProps.mInnerWindowID);
|
||||
}
|
||||
|
||||
// static
|
||||
@ -135,8 +133,7 @@ ProfilerMarkerPayload::DeserializeCommonProps(
|
||||
aEntryReader.ReadIntoObject(props.mStartTime);
|
||||
aEntryReader.ReadIntoObject(props.mEndTime);
|
||||
aEntryReader.ReadIntoObject(props.mStack);
|
||||
aEntryReader.ReadIntoObject(props.mDocShellId);
|
||||
aEntryReader.ReadIntoObject(props.mDocShellHistoryId);
|
||||
aEntryReader.ReadIntoObject(props.mInnerWindowID);
|
||||
return props;
|
||||
}
|
||||
|
||||
@ -146,12 +143,13 @@ void ProfilerMarkerPayload::StreamCommonProps(
|
||||
StreamType(aMarkerType, aWriter);
|
||||
WriteTime(aWriter, aProcessStartTime, mCommonProps.mStartTime, "startTime");
|
||||
WriteTime(aWriter, aProcessStartTime, mCommonProps.mEndTime, "endTime");
|
||||
if (mCommonProps.mDocShellId) {
|
||||
aWriter.StringProperty("docShellId", mCommonProps.mDocShellId->c_str());
|
||||
}
|
||||
if (mCommonProps.mDocShellHistoryId) {
|
||||
aWriter.DoubleProperty("docshellHistoryId",
|
||||
mCommonProps.mDocShellHistoryId.ref());
|
||||
if (mCommonProps.mInnerWindowID) {
|
||||
// Here, we are converting uint64_t to double. Both Browsing Context and
|
||||
// Inner Window IDs are creating using
|
||||
// `nsContentUtils::GenerateProcessSpecificId`, which is specifically
|
||||
// designed to only use 53 of the 64 bits to be lossless when passed into
|
||||
// and out of JS as a double.
|
||||
aWriter.DoubleProperty("innerWindowID", mCommonProps.mInnerWindowID.ref());
|
||||
}
|
||||
if (mCommonProps.mStack) {
|
||||
aWriter.StartObjectProperty("stack");
|
||||
@ -165,9 +163,8 @@ void ProfilerMarkerPayload::StreamCommonProps(
|
||||
|
||||
TracingMarkerPayload::TracingMarkerPayload(
|
||||
const char* aCategory, TracingKind aKind,
|
||||
const Maybe<std::string>& aDocShellId,
|
||||
const Maybe<uint32_t>& aDocShellHistoryId, UniqueProfilerBacktrace aCause)
|
||||
: ProfilerMarkerPayload(aDocShellId, aDocShellHistoryId, std::move(aCause)),
|
||||
const Maybe<uint64_t>& aInnerWindowID, UniqueProfilerBacktrace aCause)
|
||||
: ProfilerMarkerPayload(aInnerWindowID, std::move(aCause)),
|
||||
mCategory(aCategory),
|
||||
mKind(aKind) {}
|
||||
|
||||
@ -228,8 +225,7 @@ FileIOMarkerPayload::FileIOMarkerPayload(const char* aOperation,
|
||||
const TimeStamp& aStartTime,
|
||||
const TimeStamp& aEndTime,
|
||||
UniqueProfilerBacktrace aStack)
|
||||
: ProfilerMarkerPayload(aStartTime, aEndTime, Nothing(), Nothing(),
|
||||
std::move(aStack)),
|
||||
: ProfilerMarkerPayload(aStartTime, aEndTime, Nothing(), std::move(aStack)),
|
||||
mSource(aSource),
|
||||
mOperation(aOperation ? strdup(aOperation) : nullptr),
|
||||
mFilename(aFilename ? strdup(aFilename) : nullptr) {
|
||||
@ -287,20 +283,16 @@ void FileIOMarkerPayload::StreamPayload(SpliceableJSONWriter& aWriter,
|
||||
|
||||
UserTimingMarkerPayload::UserTimingMarkerPayload(
|
||||
const std::string& aName, const TimeStamp& aStartTime,
|
||||
const Maybe<std::string>& aDocShellId,
|
||||
const Maybe<uint32_t>& aDocShellHistoryId)
|
||||
: ProfilerMarkerPayload(aStartTime, aStartTime, aDocShellId,
|
||||
aDocShellHistoryId),
|
||||
const Maybe<uint64_t>& aInnerWindowID)
|
||||
: ProfilerMarkerPayload(aStartTime, aStartTime, aInnerWindowID),
|
||||
mEntryType("mark"),
|
||||
mName(aName) {}
|
||||
|
||||
UserTimingMarkerPayload::UserTimingMarkerPayload(
|
||||
const std::string& aName, const Maybe<std::string>& aStartMark,
|
||||
const Maybe<std::string>& aEndMark, const TimeStamp& aStartTime,
|
||||
const TimeStamp& aEndTime, const Maybe<std::string>& aDocShellId,
|
||||
const Maybe<uint32_t>& aDocShellHistoryId)
|
||||
: ProfilerMarkerPayload(aStartTime, aEndTime, aDocShellId,
|
||||
aDocShellHistoryId),
|
||||
const TimeStamp& aEndTime, const Maybe<uint64_t>& aInnerWindowID)
|
||||
: ProfilerMarkerPayload(aStartTime, aEndTime, aInnerWindowID),
|
||||
mEntryType("measure"),
|
||||
mName(aName),
|
||||
mStartMark(aStartMark),
|
||||
@ -378,20 +370,17 @@ TextMarkerPayload::TextMarkerPayload(const std::string& aText,
|
||||
|
||||
TextMarkerPayload::TextMarkerPayload(const std::string& aText,
|
||||
const TimeStamp& aStartTime,
|
||||
const Maybe<std::string>& aDocShellId,
|
||||
const Maybe<uint32_t>& aDocShellHistoryId)
|
||||
: ProfilerMarkerPayload(aStartTime, aStartTime, aDocShellId,
|
||||
aDocShellHistoryId),
|
||||
const Maybe<uint64_t>& aInnerWindowID)
|
||||
: ProfilerMarkerPayload(aStartTime, aStartTime, aInnerWindowID),
|
||||
mText(aText) {}
|
||||
|
||||
TextMarkerPayload::TextMarkerPayload(const std::string& aText,
|
||||
const TimeStamp& aStartTime,
|
||||
const TimeStamp& aEndTime,
|
||||
const Maybe<std::string>& aDocShellId,
|
||||
const Maybe<uint32_t>& aDocShellHistoryId,
|
||||
const Maybe<uint64_t>& aInnerWindowID,
|
||||
UniqueProfilerBacktrace aCause)
|
||||
: ProfilerMarkerPayload(aStartTime, aEndTime, aDocShellId,
|
||||
aDocShellHistoryId, std::move(aCause)),
|
||||
: ProfilerMarkerPayload(aStartTime, aEndTime, aInnerWindowID,
|
||||
std::move(aCause)),
|
||||
mText(aText) {}
|
||||
|
||||
TextMarkerPayload::TextMarkerPayload(CommonProps&& aCommonProps,
|
||||
|
@ -365,11 +365,11 @@ class CorePS {
|
||||
sInstance->mRegisteredPages.append(std::move(aRegisteredPage)));
|
||||
}
|
||||
|
||||
static void RemoveRegisteredPages(PSLockRef,
|
||||
const std::string& aRegisteredDocShellId) {
|
||||
// Remove RegisteredPage from mRegisteredPages by given DocShell Id.
|
||||
static void RemoveRegisteredPage(PSLockRef,
|
||||
uint64_t aRegisteredInnerWindowID) {
|
||||
// Remove RegisteredPage from mRegisteredPages by given inner window ID.
|
||||
sInstance->mRegisteredPages.eraseIf([&](const RefPtr<PageInformation>& rd) {
|
||||
return rd->DocShellId() == aRegisteredDocShellId;
|
||||
return rd->InnerWindowID() == aRegisteredInnerWindowID;
|
||||
});
|
||||
}
|
||||
|
||||
@ -430,7 +430,7 @@ class CorePS {
|
||||
Vector<UniquePtr<RegisteredThread>> mRegisteredThreads;
|
||||
|
||||
// Info on all the registered pages.
|
||||
// DocShellId and DocShellHistoryId pairs in mRegisteredPages are unique.
|
||||
// InnerWindowIDs in mRegisteredPages are unique.
|
||||
Vector<RefPtr<PageInformation>> mRegisteredPages;
|
||||
|
||||
// Non-owning pointers to all active counters
|
||||
@ -670,7 +670,7 @@ class ActivePS {
|
||||
for (auto& d : sInstance->mDeadProfiledPages) {
|
||||
MOZ_RELEASE_ASSERT(array.append(d));
|
||||
}
|
||||
// We don't need to sort the DocShells like threads since we won't show them
|
||||
// We don't need to sort the pages like threads since we won't show them
|
||||
// as a list.
|
||||
return array;
|
||||
}
|
||||
@ -741,12 +741,12 @@ class ActivePS {
|
||||
});
|
||||
}
|
||||
|
||||
static void UnregisterPages(PSLockRef aLock,
|
||||
const std::string& aRegisteredDocShellId) {
|
||||
static void UnregisterPage(PSLockRef aLock,
|
||||
uint64_t aRegisteredInnerWindowID) {
|
||||
auto& registeredPages = CorePS::RegisteredPages(aLock);
|
||||
for (size_t i = 0; i < registeredPages.length(); i++) {
|
||||
RefPtr<PageInformation>& page = registeredPages[i];
|
||||
if (page->DocShellId() == aRegisteredDocShellId) {
|
||||
if (page->InnerWindowID() == aRegisteredInnerWindowID) {
|
||||
page->NotifyUnregistered(sInstance->mProfileBuffer->BufferRangeEnd());
|
||||
MOZ_RELEASE_ASSERT(
|
||||
sInstance->mDeadProfiledPages.append(std::move(page)));
|
||||
@ -3059,23 +3059,18 @@ void profiler_unregister_thread() {
|
||||
}
|
||||
}
|
||||
|
||||
void profiler_register_page(const std::string& aDocShellId, uint32_t aHistoryId,
|
||||
const std::string& aUrl, bool aIsSubFrame) {
|
||||
DEBUG_LOG("profiler_register_page(%s, %u, %s, %d)", aDocShellId.c_str(),
|
||||
aHistoryId, aUrl.c_str(), aIsSubFrame);
|
||||
void profiler_register_page(uint64_t aBrowsingContextID,
|
||||
uint64_t aInnerWindowID, const std::string& aUrl,
|
||||
bool aIsSubFrame) {
|
||||
DEBUG_LOG("profiler_register_page(%" PRIu64 ", %" PRIu64 ", %s, %d)",
|
||||
aBrowsingContextID, aInnerWindowID, aUrl.c_str(), aIsSubFrame);
|
||||
|
||||
MOZ_RELEASE_ASSERT(CorePS::Exists());
|
||||
|
||||
PSAutoLock lock;
|
||||
|
||||
// If profiler is not active, delete all the previous page entries of the
|
||||
// given DocShell since we won't need those.
|
||||
if (!ActivePS::Exists(lock)) {
|
||||
CorePS::RemoveRegisteredPages(lock, aDocShellId);
|
||||
}
|
||||
|
||||
RefPtr<PageInformation> pageInfo =
|
||||
new PageInformation(aDocShellId, aHistoryId, aUrl, aIsSubFrame);
|
||||
RefPtr<PageInformation> pageInfo = new PageInformation(
|
||||
aBrowsingContextID, aInnerWindowID, aUrl, aIsSubFrame);
|
||||
CorePS::AppendRegisteredPage(lock, std::move(pageInfo));
|
||||
|
||||
// After appending the given page to CorePS, look for the expired
|
||||
@ -3085,7 +3080,7 @@ void profiler_register_page(const std::string& aDocShellId, uint32_t aHistoryId,
|
||||
}
|
||||
}
|
||||
|
||||
void profiler_unregister_pages(const std::string& aRegisteredDocShellId) {
|
||||
void profiler_unregister_page(uint64_t aRegisteredInnerWindowID) {
|
||||
if (!CorePS::Exists()) {
|
||||
// This function can be called after the main thread has already shut down.
|
||||
return;
|
||||
@ -3098,9 +3093,9 @@ void profiler_unregister_pages(const std::string& aRegisteredDocShellId) {
|
||||
// page. But if profiler is not active. we have no reason to keep the
|
||||
// page information here because there can't be any marker associated with it.
|
||||
if (ActivePS::Exists(lock)) {
|
||||
ActivePS::UnregisterPages(lock, aRegisteredDocShellId);
|
||||
ActivePS::UnregisterPage(lock, aRegisteredInnerWindowID);
|
||||
} else {
|
||||
CorePS::RemoveRegisteredPages(lock, aRegisteredDocShellId);
|
||||
CorePS::RemoveRegisteredPage(lock, aRegisteredInnerWindowID);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3312,8 +3307,26 @@ void profiler_add_marker_for_thread(int aThreadId,
|
||||
|
||||
void profiler_tracing(const char* aCategoryString, const char* aMarkerName,
|
||||
ProfilingCategoryPair aCategoryPair, TracingKind aKind,
|
||||
const Maybe<std::string>& aDocShellId,
|
||||
const Maybe<uint32_t>& aDocShellHistoryId) {
|
||||
const Maybe<uint64_t>& aInnerWindowID) {
|
||||
MOZ_RELEASE_ASSERT(CorePS::Exists());
|
||||
|
||||
VTUNE_TRACING(aMarkerName, aKind);
|
||||
|
||||
// This function is hot enough that we use RacyFeatures, notActivePS.
|
||||
if (!profiler_can_accept_markers()) {
|
||||
return;
|
||||
}
|
||||
|
||||
AUTO_PROFILER_STATS(base_add_marker_with_TracingMarkerPayload);
|
||||
profiler_add_marker(
|
||||
aMarkerName, aCategoryPair,
|
||||
TracingMarkerPayload(aCategoryString, aKind, aInnerWindowID));
|
||||
}
|
||||
|
||||
void profiler_tracing(const char* aCategoryString, const char* aMarkerName,
|
||||
ProfilingCategoryPair aCategoryPair, TracingKind aKind,
|
||||
UniqueProfilerBacktrace aCause,
|
||||
const Maybe<uint64_t>& aInnerWindowID) {
|
||||
MOZ_RELEASE_ASSERT(CorePS::Exists());
|
||||
|
||||
VTUNE_TRACING(aMarkerName, aKind);
|
||||
@ -3325,43 +3338,20 @@ void profiler_tracing(const char* aCategoryString, const char* aMarkerName,
|
||||
|
||||
AUTO_PROFILER_STATS(base_add_marker_with_TracingMarkerPayload);
|
||||
profiler_add_marker(aMarkerName, aCategoryPair,
|
||||
TracingMarkerPayload(aCategoryString, aKind, aDocShellId,
|
||||
aDocShellHistoryId));
|
||||
}
|
||||
|
||||
void profiler_tracing(const char* aCategoryString, const char* aMarkerName,
|
||||
ProfilingCategoryPair aCategoryPair, TracingKind aKind,
|
||||
UniqueProfilerBacktrace aCause,
|
||||
const Maybe<std::string>& aDocShellId,
|
||||
const Maybe<uint32_t>& aDocShellHistoryId) {
|
||||
MOZ_RELEASE_ASSERT(CorePS::Exists());
|
||||
|
||||
VTUNE_TRACING(aMarkerName, aKind);
|
||||
|
||||
// This function is hot enough that we use RacyFeatures, notActivePS.
|
||||
if (!profiler_can_accept_markers()) {
|
||||
return;
|
||||
}
|
||||
|
||||
AUTO_PROFILER_STATS(base_add_marker_with_TracingMarkerPayload);
|
||||
profiler_add_marker(
|
||||
aMarkerName, aCategoryPair,
|
||||
TracingMarkerPayload(aCategoryString, aKind, aDocShellId,
|
||||
aDocShellHistoryId, std::move(aCause)));
|
||||
TracingMarkerPayload(aCategoryString, aKind,
|
||||
aInnerWindowID, std::move(aCause)));
|
||||
}
|
||||
|
||||
void profiler_add_text_marker(const char* aMarkerName, const std::string& aText,
|
||||
ProfilingCategoryPair aCategoryPair,
|
||||
const TimeStamp& aStartTime,
|
||||
const TimeStamp& aEndTime,
|
||||
const Maybe<std::string>& aDocShellId,
|
||||
const Maybe<uint32_t>& aDocShellHistoryId,
|
||||
const Maybe<uint64_t>& aInnerWindowID,
|
||||
UniqueProfilerBacktrace aCause) {
|
||||
AUTO_PROFILER_STATS(base_add_marker_with_TextMarkerPayload);
|
||||
profiler_add_marker(
|
||||
aMarkerName, aCategoryPair,
|
||||
TextMarkerPayload(aText, aStartTime, aEndTime, aDocShellId,
|
||||
aDocShellHistoryId, std::move(aCause)));
|
||||
profiler_add_marker(aMarkerName, aCategoryPair,
|
||||
TextMarkerPayload(aText, aStartTime, aEndTime,
|
||||
aInnerWindowID, std::move(aCause)));
|
||||
}
|
||||
|
||||
// NOTE: aCollector's methods will be called while the target thread is paused.
|
||||
|
@ -68,19 +68,10 @@
|
||||
# define BASE_PROFILER_ADD_MARKER_WITH_PAYLOAD( \
|
||||
markerName, categoryPair, PayloadType, parenthesizedPayloadArgs)
|
||||
|
||||
# define MOZDECLARE_DOCSHELL_AND_HISTORY_ID(docShell)
|
||||
# define BASE_PROFILER_TRACING(categoryString, markerName, categoryPair, kind)
|
||||
# define BASE_PROFILER_TRACING_DOCSHELL(categoryString, markerName, \
|
||||
categoryPair, kind, docshell)
|
||||
# define AUTO_BASE_PROFILER_TRACING(categoryString, markerName, categoryPair)
|
||||
# define AUTO_BASE_PROFILER_TRACING_DOCSHELL(categoryString, markerName, \
|
||||
categoryPair, docShell)
|
||||
# define AUTO_BASE_PROFILER_TEXT_MARKER_CAUSE(markerName, text, categoryPair, \
|
||||
cause)
|
||||
# define AUTO_BASE_PROFILER_TEXT_MARKER_DOCSHELL(markerName, text, \
|
||||
categoryPair, docShell)
|
||||
# define AUTO_BASE_PROFILER_TEXT_MARKER_DOCSHELL_CAUSE( \
|
||||
markerName, text, categoryPair, docShell, cause)
|
||||
|
||||
# define AUTO_PROFILER_STATS(name)
|
||||
|
||||
@ -330,32 +321,30 @@ MFBT_API ProfilingStack* profiler_register_thread(const char* name,
|
||||
void* guessStackTop);
|
||||
MFBT_API void profiler_unregister_thread();
|
||||
|
||||
// Register pages with the profiler.
|
||||
// Registers a DOM Window (the JS global `window`) with the profiler. Each
|
||||
// Window _roughly_ corresponds to a single document loaded within a
|
||||
// BrowsingContext. The unique IDs for both the Window and BrowsingContext are
|
||||
// recorded to allow correlating different Windows loaded within the same tab or
|
||||
// frame element.
|
||||
//
|
||||
// The `page` means every new history entry for docShells.
|
||||
// DocShellId + HistoryID is a unique pair to identify these pages.
|
||||
// We also keep these pairs inside markers to associate with the pages.
|
||||
// That allows us to see which markers belong to a specific page and filter the
|
||||
// markers by a page.
|
||||
// We register pages in these cases:
|
||||
// - If there is a navigation through a link or URL bar.
|
||||
// - If there is a navigation through `location.replace` or `history.pushState`.
|
||||
// We do not register pages in these cases:
|
||||
// - If there is a history navigation through the back and forward buttons.
|
||||
// - If there is a navigation through `history.replaceState` or anchor scrolls.
|
||||
// We register pages for each navigations but we do not register
|
||||
// history.pushState or history.replaceState since they correspond to the same
|
||||
// Inner Window ID.
|
||||
//
|
||||
// "aDocShellId" is the ID of the docShell that page belongs to.
|
||||
// "aHistoryId" is the ID of the history entry on the given docShell.
|
||||
// "aUrl" is the URL of the page.
|
||||
// "aIsSubFrame" is true if the page is a sub frame.
|
||||
MFBT_API void profiler_register_page(const std::string& aDocShellId,
|
||||
uint32_t aHistoryId,
|
||||
// "aBrowsingContextID" is the ID of the browsing context that document
|
||||
// belongs to. That's used to determine the tab of that
|
||||
// page.
|
||||
// "aInnerWindowID" is the ID of the `window` global object of that
|
||||
// document.
|
||||
// "aUrl" is the URL of the page.
|
||||
// "aIsSubFrame" is true if the page is a sub frame.
|
||||
MFBT_API void profiler_register_page(uint64_t aBrowsingContextID,
|
||||
uint64_t aInnerWindowID,
|
||||
const std::string& aUrl, bool aIsSubFrame);
|
||||
// Unregister pages with the profiler.
|
||||
// Unregister page with the profiler.
|
||||
//
|
||||
// Take a docShellId and unregister all the page entries that have the given ID.
|
||||
MFBT_API void profiler_unregister_pages(
|
||||
const std::string& aRegisteredDocShellId);
|
||||
// Take a Inner Window ID and unregister the page entry that has the same ID.
|
||||
MFBT_API void profiler_unregister_page(uint64_t aRegisteredInnerWindowID);
|
||||
|
||||
// Remove all registered and unregistered pages in the profiler.
|
||||
void profiler_clear_all_pages();
|
||||
@ -756,24 +745,6 @@ enum TracingKind {
|
||||
TRACING_INTERVAL_END,
|
||||
};
|
||||
|
||||
// Helper macro to retrieve DocShellId and DocShellHistoryId from docShell
|
||||
# define MOZDECLARE_DOCSHELL_AND_HISTORY_ID(docShell) \
|
||||
Maybe<std::string> docShellId; \
|
||||
Maybe<uint32_t> docShellHistoryId; \
|
||||
if (docShell) { \
|
||||
docShellId = mozilla::Some(docShell->HistoryID()); \
|
||||
uint32_t id; \
|
||||
nsresult rv = docShell->GetOSHEId(&id); \
|
||||
if (NS_SUCCEEDED(rv)) { \
|
||||
docShellHistoryId = mozilla::Some(id); \
|
||||
} else { \
|
||||
docShellHistoryId = mozilla::Nothing(); \
|
||||
} \
|
||||
} else { \
|
||||
docShellId = mozilla::Nothing(); \
|
||||
docShellHistoryId = mozilla::Nothing(); \
|
||||
}
|
||||
|
||||
// Adds a tracing marker to the profile. A no-op if the profiler is inactive or
|
||||
// in privacy mode.
|
||||
|
||||
@ -782,39 +753,23 @@ enum TracingKind {
|
||||
::mozilla::baseprofiler::profiler_tracing( \
|
||||
categoryString, markerName, \
|
||||
::mozilla::baseprofiler::ProfilingCategoryPair::categoryPair, kind)
|
||||
# define BASE_PROFILER_TRACING_DOCSHELL(categoryString, markerName, \
|
||||
categoryPair, kind, docShell) \
|
||||
MOZDECLARE_DOCSHELL_AND_HISTORY_ID(docShell); \
|
||||
::mozilla::baseprofiler::profiler_tracing( \
|
||||
categoryString, markerName, \
|
||||
::mozilla::baseprofiler::ProfilingCategoryPair::categoryPair, kind, \
|
||||
docShellId, docShellHistoryId)
|
||||
|
||||
MFBT_API void profiler_tracing(
|
||||
const char* aCategoryString, const char* aMarkerName,
|
||||
ProfilingCategoryPair aCategoryPair, TracingKind aKind,
|
||||
const Maybe<std::string>& aDocShellId = Nothing(),
|
||||
const Maybe<uint32_t>& aDocShellHistoryId = Nothing());
|
||||
const Maybe<uint64_t>& aInnerWindowID = Nothing());
|
||||
MFBT_API void profiler_tracing(
|
||||
const char* aCategoryString, const char* aMarkerName,
|
||||
ProfilingCategoryPair aCategoryPair, TracingKind aKind,
|
||||
UniqueProfilerBacktrace aCause,
|
||||
const Maybe<std::string>& aDocShellId = Nothing(),
|
||||
const Maybe<uint32_t>& aDocShellHistoryId = Nothing());
|
||||
const Maybe<uint64_t>& aInnerWindowID = Nothing());
|
||||
|
||||
// Adds a START/END pair of tracing markers.
|
||||
# define AUTO_BASE_PROFILER_TRACING(categoryString, markerName, categoryPair) \
|
||||
::mozilla::baseprofiler::AutoProfilerTracing BASE_PROFILER_RAII( \
|
||||
categoryString, markerName, \
|
||||
::mozilla::baseprofiler::ProfilingCategoryPair::categoryPair, \
|
||||
Nothing(), Nothing())
|
||||
# define AUTO_BASE_PROFILER_TRACING_DOCSHELL(categoryString, markerName, \
|
||||
categoryPair, docShell) \
|
||||
MOZDECLARE_DOCSHELL_AND_HISTORY_ID(docShell); \
|
||||
::mozilla::baseprofiler::AutoProfilerTracing BASE_PROFILER_RAII( \
|
||||
categoryString, markerName, \
|
||||
::mozilla::baseprofiler::ProfilingCategoryPair::categoryPair, \
|
||||
docShellId, docShellHistoryId)
|
||||
Nothing())
|
||||
|
||||
// Add a text marker. Text markers are similar to tracing markers, with the
|
||||
// difference that text markers have their "text" separate from the marker name;
|
||||
@ -826,16 +781,14 @@ MFBT_API void profiler_add_text_marker(
|
||||
const char* aMarkerName, const std::string& aText,
|
||||
ProfilingCategoryPair aCategoryPair, const TimeStamp& aStartTime,
|
||||
const TimeStamp& aEndTime,
|
||||
const Maybe<std::string>& aDocShellId = Nothing(),
|
||||
const Maybe<uint32_t>& aDocShellHistoryId = Nothing(),
|
||||
const Maybe<uint64_t>& aInnerWindowID = Nothing(),
|
||||
UniqueProfilerBacktrace aCause = nullptr);
|
||||
|
||||
class MOZ_RAII AutoProfilerTextMarker {
|
||||
public:
|
||||
AutoProfilerTextMarker(const char* aMarkerName, const std::string& aText,
|
||||
ProfilingCategoryPair aCategoryPair,
|
||||
const Maybe<std::string>& aDocShellId,
|
||||
const Maybe<uint32_t>& aDocShellHistoryId,
|
||||
const Maybe<uint64_t>& aInnerWindowID,
|
||||
UniqueProfilerBacktrace&& aCause =
|
||||
nullptr MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: mMarkerName(aMarkerName),
|
||||
@ -843,15 +796,14 @@ class MOZ_RAII AutoProfilerTextMarker {
|
||||
mCategoryPair(aCategoryPair),
|
||||
mStartTime(TimeStamp::NowUnfuzzed()),
|
||||
mCause(std::move(aCause)),
|
||||
mDocShellId(aDocShellId),
|
||||
mDocShellHistoryId(aDocShellHistoryId) {
|
||||
mInnerWindowID(aInnerWindowID) {
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
}
|
||||
|
||||
~AutoProfilerTextMarker() {
|
||||
profiler_add_text_marker(mMarkerName, mText, mCategoryPair, mStartTime,
|
||||
TimeStamp::NowUnfuzzed(), mDocShellId,
|
||||
mDocShellHistoryId, std::move(mCause));
|
||||
TimeStamp::NowUnfuzzed(), mInnerWindowID,
|
||||
std::move(mCause));
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -861,8 +813,7 @@ class MOZ_RAII AutoProfilerTextMarker {
|
||||
const ProfilingCategoryPair mCategoryPair;
|
||||
TimeStamp mStartTime;
|
||||
UniqueProfilerBacktrace mCause;
|
||||
const Maybe<std::string> mDocShellId;
|
||||
const Maybe<uint32_t> mDocShellHistoryId;
|
||||
const Maybe<uint64_t> mInnerWindowID;
|
||||
};
|
||||
|
||||
# define AUTO_BASE_PROFILER_TEXT_MARKER_CAUSE(markerName, text, categoryPair, \
|
||||
@ -870,23 +821,7 @@ class MOZ_RAII AutoProfilerTextMarker {
|
||||
::mozilla::baseprofiler::AutoProfilerTextMarker BASE_PROFILER_RAII( \
|
||||
markerName, text, \
|
||||
::mozilla::baseprofiler::ProfilingCategoryPair::categoryPair, \
|
||||
mozilla::Nothing(), mozilla::Nothing(), cause)
|
||||
|
||||
# define AUTO_BASE_PROFILER_TEXT_MARKER_DOCSHELL(markerName, text, \
|
||||
categoryPair, docShell) \
|
||||
MOZDECLARE_DOCSHELL_AND_HISTORY_ID(docShell); \
|
||||
::mozilla::baseprofiler::AutoProfilerTextMarker BASE_PROFILER_RAII( \
|
||||
markerName, text, \
|
||||
::mozilla::baseprofiler::ProfilingCategoryPair::categoryPair, \
|
||||
docShellId, docShellHistoryId)
|
||||
|
||||
# define AUTO_BASE_PROFILER_TEXT_MARKER_DOCSHELL_CAUSE( \
|
||||
markerName, text, categoryPair, docShell, cause) \
|
||||
MOZDECLARE_DOCSHELL_AND_HISTORY_ID(docShell); \
|
||||
::mozilla::baseprofiler::AutoProfilerTextMarker BASE_PROFILER_RAII( \
|
||||
markerName, text, \
|
||||
::mozilla::baseprofiler::ProfilingCategoryPair::categoryPair, \
|
||||
docShellId, docShellHistoryId, cause)
|
||||
mozilla::Nothing(), cause)
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Output profiles
|
||||
@ -1041,38 +976,34 @@ class MOZ_RAII AutoProfilerTracing {
|
||||
public:
|
||||
AutoProfilerTracing(const char* aCategoryString, const char* aMarkerName,
|
||||
ProfilingCategoryPair aCategoryPair,
|
||||
const Maybe<std::string>& aDocShellId,
|
||||
const Maybe<uint32_t>& aDocShellHistoryId
|
||||
const Maybe<uint64_t>& aInnerWindowID
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: mCategoryString(aCategoryString),
|
||||
mMarkerName(aMarkerName),
|
||||
mCategoryPair(aCategoryPair),
|
||||
mDocShellId(aDocShellId),
|
||||
mDocShellHistoryId(aDocShellHistoryId) {
|
||||
mInnerWindowID(aInnerWindowID) {
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
profiler_tracing(mCategoryString, mMarkerName, aCategoryPair,
|
||||
TRACING_INTERVAL_START, mDocShellId, mDocShellHistoryId);
|
||||
TRACING_INTERVAL_START, mInnerWindowID);
|
||||
}
|
||||
|
||||
AutoProfilerTracing(
|
||||
const char* aCategoryString, const char* aMarkerName,
|
||||
ProfilingCategoryPair aCategoryPair, UniqueProfilerBacktrace aBacktrace,
|
||||
const Maybe<std::string>& aDocShellId,
|
||||
const Maybe<uint32_t>& aDocShellHistoryId MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
const Maybe<uint64_t>& aInnerWindowID MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: mCategoryString(aCategoryString),
|
||||
mMarkerName(aMarkerName),
|
||||
mCategoryPair(aCategoryPair),
|
||||
mDocShellId(aDocShellId),
|
||||
mDocShellHistoryId(aDocShellHistoryId) {
|
||||
mInnerWindowID(aInnerWindowID) {
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
profiler_tracing(mCategoryString, mMarkerName, aCategoryPair,
|
||||
TRACING_INTERVAL_START, std::move(aBacktrace), mDocShellId,
|
||||
mDocShellHistoryId);
|
||||
TRACING_INTERVAL_START, std::move(aBacktrace),
|
||||
mInnerWindowID);
|
||||
}
|
||||
|
||||
~AutoProfilerTracing() {
|
||||
profiler_tracing(mCategoryString, mMarkerName, mCategoryPair,
|
||||
TRACING_INTERVAL_END, mDocShellId, mDocShellHistoryId);
|
||||
TRACING_INTERVAL_END, mInnerWindowID);
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -1080,8 +1011,7 @@ class MOZ_RAII AutoProfilerTracing {
|
||||
const char* mCategoryString;
|
||||
const char* mMarkerName;
|
||||
const ProfilingCategoryPair mCategoryPair;
|
||||
const Maybe<std::string> mDocShellId;
|
||||
const Maybe<uint32_t> mDocShellHistoryId;
|
||||
const Maybe<uint64_t> mInnerWindowID;
|
||||
};
|
||||
|
||||
// Get the MOZ_BASE_PROFILER_STARTUP* environment variables that should be
|
||||
|
@ -36,18 +36,15 @@ class UniqueStacks;
|
||||
class ProfilerMarkerPayload {
|
||||
public:
|
||||
explicit ProfilerMarkerPayload(
|
||||
const Maybe<std::string>& aDocShellId = Nothing(),
|
||||
const Maybe<uint32_t>& aDocShellHistoryId = Nothing(),
|
||||
const Maybe<uint64_t>& aInnerWindowID = Nothing(),
|
||||
UniqueProfilerBacktrace aStack = nullptr)
|
||||
: mCommonProps{TimeStamp{}, TimeStamp{}, std::move(aStack),
|
||||
std::move(aDocShellId), std::move(aDocShellHistoryId)} {}
|
||||
aInnerWindowID} {}
|
||||
|
||||
ProfilerMarkerPayload(const TimeStamp& aStartTime, const TimeStamp& aEndTime,
|
||||
const Maybe<std::string>& aDocShellId = Nothing(),
|
||||
const Maybe<uint32_t>& aDocShellHistoryId = Nothing(),
|
||||
const Maybe<uint64_t>& aInnerWindowID = Nothing(),
|
||||
UniqueProfilerBacktrace aStack = nullptr)
|
||||
: mCommonProps{aStartTime, aEndTime, std::move(aStack),
|
||||
std::move(aDocShellId), std::move(aDocShellHistoryId)} {}
|
||||
: mCommonProps{aStartTime, aEndTime, std::move(aStack), aInnerWindowID} {}
|
||||
|
||||
virtual ~ProfilerMarkerPayload() {}
|
||||
|
||||
@ -130,8 +127,7 @@ class ProfilerMarkerPayload {
|
||||
TimeStamp mStartTime;
|
||||
TimeStamp mEndTime;
|
||||
UniqueProfilerBacktrace mStack;
|
||||
Maybe<std::string> mDocShellId;
|
||||
Maybe<uint32_t> mDocShellHistoryId;
|
||||
Maybe<uint64_t> mInnerWindowID;
|
||||
};
|
||||
|
||||
// Deserializers can use this base constructor.
|
||||
@ -178,14 +174,13 @@ class ProfilerMarkerPayload {
|
||||
MFBT_API void SerializeTagAndPayload( \
|
||||
BlocksRingBuffer::EntryWriter& aEntryWriter) const override;
|
||||
|
||||
// TODO: Increase the coverage of tracing markers that include DocShell
|
||||
// TODO: Increase the coverage of tracing markers that include InnerWindowID
|
||||
// information
|
||||
class TracingMarkerPayload : public ProfilerMarkerPayload {
|
||||
public:
|
||||
MFBT_API TracingMarkerPayload(
|
||||
const char* aCategory, TracingKind aKind,
|
||||
const Maybe<std::string>& aDocShellId = Nothing(),
|
||||
const Maybe<uint32_t>& aDocShellHistoryId = Nothing(),
|
||||
const Maybe<uint64_t>& aInnerWindowID = Nothing(),
|
||||
UniqueProfilerBacktrace aCause = nullptr);
|
||||
|
||||
MFBT_API ~TracingMarkerPayload() override;
|
||||
@ -226,16 +221,14 @@ class UserTimingMarkerPayload : public ProfilerMarkerPayload {
|
||||
public:
|
||||
MFBT_API UserTimingMarkerPayload(const std::string& aName,
|
||||
const TimeStamp& aStartTime,
|
||||
const Maybe<std::string>& aDocShellId,
|
||||
const Maybe<uint32_t>& aDocShellHistoryId);
|
||||
const Maybe<uint64_t>& aInnerWindowID);
|
||||
|
||||
MFBT_API UserTimingMarkerPayload(const std::string& aName,
|
||||
const Maybe<std::string>& aStartMark,
|
||||
const Maybe<std::string>& aEndMark,
|
||||
const TimeStamp& aStartTime,
|
||||
const TimeStamp& aEndTime,
|
||||
const Maybe<std::string>& aDocShellId,
|
||||
const Maybe<uint32_t>& aDocShellHistoryId);
|
||||
const Maybe<uint64_t>& aInnerWindowID);
|
||||
|
||||
MFBT_API ~UserTimingMarkerPayload() override;
|
||||
|
||||
@ -291,14 +284,12 @@ class TextMarkerPayload : public ProfilerMarkerPayload {
|
||||
|
||||
MFBT_API TextMarkerPayload(const std::string& aText,
|
||||
const TimeStamp& aStartTime,
|
||||
const Maybe<std::string>& aDocShellId,
|
||||
const Maybe<uint32_t>& aDocShellHistoryId);
|
||||
const Maybe<uint64_t>& aInnerWindowID);
|
||||
|
||||
MFBT_API TextMarkerPayload(const std::string& aText,
|
||||
const TimeStamp& aStartTime,
|
||||
const TimeStamp& aEndTime,
|
||||
const Maybe<std::string>& aDocShellId,
|
||||
const Maybe<uint32_t>& aDocShellHistoryId,
|
||||
const Maybe<uint64_t>& aInnerWindowID,
|
||||
UniqueProfilerBacktrace aCause = nullptr);
|
||||
|
||||
MFBT_API ~TextMarkerPayload() override;
|
||||
|
@ -1712,7 +1712,7 @@ void TestProfiler() {
|
||||
baseprofiler::profiler_add_marker(
|
||||
"UserTimingMarkerPayload", baseprofiler::ProfilingCategoryPair::OTHER,
|
||||
baseprofiler::UserTimingMarkerPayload("name", TimeStamp::NowUnfuzzed(),
|
||||
Nothing{}, Nothing{}));
|
||||
Nothing{}));
|
||||
|
||||
baseprofiler::profiler_add_marker(
|
||||
"HangMarkerPayload", baseprofiler::ProfilingCategoryPair::OTHER,
|
||||
|
@ -8,24 +8,28 @@
|
||||
|
||||
#include "ProfileJSONWriter.h"
|
||||
|
||||
PageInformation::PageInformation(const nsID& aDocShellId,
|
||||
uint32_t aDocShellHistoryId,
|
||||
const nsCString& aUrl, bool aIsSubFrame)
|
||||
: mDocShellId(aDocShellId),
|
||||
mDocShellHistoryId(aDocShellHistoryId),
|
||||
PageInformation::PageInformation(uint64_t aBrowsingContextID,
|
||||
uint64_t aInnerWindowID, const nsCString& aUrl,
|
||||
bool aIsSubFrame)
|
||||
: mBrowsingContextID(aBrowsingContextID),
|
||||
mInnerWindowID(aInnerWindowID),
|
||||
mUrl(aUrl),
|
||||
mIsSubFrame(aIsSubFrame) {}
|
||||
|
||||
bool PageInformation::Equals(PageInformation* aOtherPageInfo) {
|
||||
return DocShellHistoryId() == aOtherPageInfo->DocShellHistoryId() &&
|
||||
DocShellId().Equals(aOtherPageInfo->DocShellId()) &&
|
||||
IsSubFrame() == aOtherPageInfo->IsSubFrame();
|
||||
bool PageInformation::Equals(PageInformation* aOtherPageInfo) const {
|
||||
// It's enough to check inner window IDs because they are unique for each
|
||||
// page. Therefore, we don't have to check browsing context ID or url.
|
||||
return InnerWindowID() == aOtherPageInfo->InnerWindowID();
|
||||
}
|
||||
|
||||
void PageInformation::StreamJSON(SpliceableJSONWriter& aWriter) {
|
||||
void PageInformation::StreamJSON(SpliceableJSONWriter& aWriter) const {
|
||||
// Here, we are converting uint64_t to double. Both Browsing Context and Inner
|
||||
// Window IDs are creating using `nsContentUtils::GenerateProcessSpecificId`,
|
||||
// which is specifically designed to only use 53 of the 64 bits to be lossless
|
||||
// when passed into and out of JS as a double.
|
||||
aWriter.StartObjectElement();
|
||||
aWriter.StringProperty("docshellId", nsIDToCString(DocShellId()).get());
|
||||
aWriter.DoubleProperty("historyId", DocShellHistoryId());
|
||||
aWriter.DoubleProperty("browsingContextID", BrowsingContextID());
|
||||
aWriter.DoubleProperty("innerWindowID", InnerWindowID());
|
||||
aWriter.StringProperty("url", Url().get());
|
||||
aWriter.BoolProperty("isSubFrame", IsSubFrame());
|
||||
aWriter.EndObject();
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "nsID.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
#include "nsString.h"
|
||||
|
||||
@ -25,19 +24,19 @@ class SpliceableJSONWriter;
|
||||
class PageInformation final {
|
||||
public:
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(PageInformation)
|
||||
PageInformation(const nsID& aDocShellId, uint32_t aDocShellHistoryId,
|
||||
PageInformation(uint64_t aBrowsingContextID, uint64_t aInnerWindowID,
|
||||
const nsCString& aUrl, bool aIsSubFrame);
|
||||
|
||||
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
||||
bool Equals(PageInformation* aOtherDocShellInfo);
|
||||
void StreamJSON(SpliceableJSONWriter& aWriter);
|
||||
bool Equals(PageInformation* aOtherPageInfo) const;
|
||||
void StreamJSON(SpliceableJSONWriter& aWriter) const;
|
||||
|
||||
uint32_t DocShellHistoryId() { return mDocShellHistoryId; }
|
||||
const nsID& DocShellId() { return mDocShellId; }
|
||||
const nsCString& Url() { return mUrl; }
|
||||
bool IsSubFrame() { return mIsSubFrame; }
|
||||
uint64_t InnerWindowID() const { return mInnerWindowID; }
|
||||
uint64_t BrowsingContextID() const { return mBrowsingContextID; }
|
||||
const nsCString& Url() const { return mUrl; }
|
||||
bool IsSubFrame() const { return mIsSubFrame; }
|
||||
|
||||
mozilla::Maybe<uint64_t> BufferPositionWhenUnregistered() {
|
||||
mozilla::Maybe<uint64_t> BufferPositionWhenUnregistered() const {
|
||||
return mBufferPositionWhenUnregistered;
|
||||
}
|
||||
|
||||
@ -46,13 +45,13 @@ class PageInformation final {
|
||||
}
|
||||
|
||||
private:
|
||||
const nsID mDocShellId;
|
||||
const uint32_t mDocShellHistoryId;
|
||||
const uint64_t mBrowsingContextID;
|
||||
const uint64_t mInnerWindowID;
|
||||
const nsCString mUrl;
|
||||
const bool mIsSubFrame;
|
||||
|
||||
// Holds the buffer position when DocShell is unregistered.
|
||||
// It's used to determine if we still use this DocShell in the profiler or
|
||||
// Holds the buffer position when page is unregistered.
|
||||
// It's used to determine if we still use this page in the profiler or
|
||||
// not.
|
||||
mozilla::Maybe<uint64_t> mBufferPositionWhenUnregistered;
|
||||
|
||||
|
@ -112,8 +112,7 @@ ProfilerMarkerPayload::CommonPropsTagAndSerializationBytes() const {
|
||||
return sizeof(DeserializerTag) +
|
||||
BlocksRingBuffer::SumBytes(mCommonProps.mStartTime,
|
||||
mCommonProps.mEndTime, mCommonProps.mStack,
|
||||
mCommonProps.mDocShellId,
|
||||
mCommonProps.mDocShellHistoryId);
|
||||
mCommonProps.mInnerWindowID);
|
||||
}
|
||||
|
||||
void ProfilerMarkerPayload::SerializeTagAndCommonProps(
|
||||
@ -123,8 +122,7 @@ void ProfilerMarkerPayload::SerializeTagAndCommonProps(
|
||||
aEntryWriter.WriteObject(mCommonProps.mStartTime);
|
||||
aEntryWriter.WriteObject(mCommonProps.mEndTime);
|
||||
aEntryWriter.WriteObject(mCommonProps.mStack);
|
||||
aEntryWriter.WriteObject(mCommonProps.mDocShellId);
|
||||
aEntryWriter.WriteObject(mCommonProps.mDocShellHistoryId);
|
||||
aEntryWriter.WriteObject(mCommonProps.mInnerWindowID);
|
||||
}
|
||||
|
||||
// static
|
||||
@ -135,8 +133,7 @@ ProfilerMarkerPayload::DeserializeCommonProps(
|
||||
aEntryReader.ReadIntoObject(props.mStartTime);
|
||||
aEntryReader.ReadIntoObject(props.mEndTime);
|
||||
aEntryReader.ReadIntoObject(props.mStack);
|
||||
aEntryReader.ReadIntoObject(props.mDocShellId);
|
||||
aEntryReader.ReadIntoObject(props.mDocShellHistoryId);
|
||||
aEntryReader.ReadIntoObject(props.mInnerWindowID);
|
||||
return props;
|
||||
}
|
||||
|
||||
@ -146,13 +143,13 @@ void ProfilerMarkerPayload::StreamCommonProps(
|
||||
StreamType(aMarkerType, aWriter);
|
||||
WriteTime(aWriter, aProcessStartTime, mCommonProps.mStartTime, "startTime");
|
||||
WriteTime(aWriter, aProcessStartTime, mCommonProps.mEndTime, "endTime");
|
||||
if (mCommonProps.mDocShellId) {
|
||||
aWriter.StringProperty("docShellId",
|
||||
nsIDToCString(*mCommonProps.mDocShellId).get());
|
||||
}
|
||||
if (mCommonProps.mDocShellHistoryId) {
|
||||
aWriter.DoubleProperty("docshellHistoryId",
|
||||
mCommonProps.mDocShellHistoryId.ref());
|
||||
if (mCommonProps.mInnerWindowID) {
|
||||
// Here, we are converting uint64_t to double. Both Browsing Context and
|
||||
// Inner Window IDs are creating using
|
||||
// `nsContentUtils::GenerateProcessSpecificId`, which is specifically
|
||||
// designed to only use 53 of the 64 bits to be lossless when passed into
|
||||
// and out of JS as a double.
|
||||
aWriter.DoubleProperty("innerWindowID", mCommonProps.mInnerWindowID.ref());
|
||||
}
|
||||
if (mCommonProps.mStack) {
|
||||
aWriter.StartObjectProperty("stack");
|
||||
|
@ -63,6 +63,7 @@
|
||||
#include "BaseProfiler.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsDirectoryServiceUtils.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIHttpProtocolHandler.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIPropertyBag2.h"
|
||||
@ -437,11 +438,11 @@ class CorePS {
|
||||
sInstance->mRegisteredPages.append(std::move(aRegisteredPage)));
|
||||
}
|
||||
|
||||
static void RemoveRegisteredPages(PSLockRef,
|
||||
const nsID& aRegisteredDocShellId) {
|
||||
// Remove RegisteredPage from mRegisteredPages by given DocShell Id.
|
||||
static void RemoveRegisteredPage(PSLockRef,
|
||||
uint64_t aRegisteredInnerWindowID) {
|
||||
// Remove RegisteredPage from mRegisteredPages by given inner window ID.
|
||||
sInstance->mRegisteredPages.eraseIf([&](const RefPtr<PageInformation>& rd) {
|
||||
return rd->DocShellId().Equals(aRegisteredDocShellId);
|
||||
return rd->InnerWindowID() == aRegisteredInnerWindowID;
|
||||
});
|
||||
}
|
||||
|
||||
@ -499,7 +500,7 @@ class CorePS {
|
||||
Vector<UniquePtr<RegisteredThread>> mRegisteredThreads;
|
||||
|
||||
// Info on all the registered pages.
|
||||
// DocShellId and DocShellHistoryId pairs in mRegisteredPages are unique.
|
||||
// InnerWindowIDs in mRegisteredPages are unique.
|
||||
Vector<RefPtr<PageInformation>> mRegisteredPages;
|
||||
|
||||
// Non-owning pointers to all active counters
|
||||
@ -793,7 +794,7 @@ class ActivePS {
|
||||
for (auto& d : sInstance->mDeadProfiledPages) {
|
||||
MOZ_RELEASE_ASSERT(array.append(d));
|
||||
}
|
||||
// We don't need to sort the DocShells like threads since we won't show them
|
||||
// We don't need to sort the pages like threads since we won't show them
|
||||
// as a list.
|
||||
return array;
|
||||
}
|
||||
@ -864,12 +865,12 @@ class ActivePS {
|
||||
});
|
||||
}
|
||||
|
||||
static void UnregisterPages(PSLockRef aLock,
|
||||
const nsID& aRegisteredDocShellId) {
|
||||
static void UnregisterPage(PSLockRef aLock,
|
||||
uint64_t aRegisteredInnerWindowID) {
|
||||
auto& registeredPages = CorePS::RegisteredPages(aLock);
|
||||
for (size_t i = 0; i < registeredPages.length(); i++) {
|
||||
RefPtr<PageInformation>& page = registeredPages[i];
|
||||
if (page->DocShellId().Equals(aRegisteredDocShellId)) {
|
||||
if (page->InnerWindowID() == aRegisteredInnerWindowID) {
|
||||
page->NotifyUnregistered(sInstance->mProfileBuffer->BufferRangeEnd());
|
||||
MOZ_RELEASE_ASSERT(
|
||||
sInstance->mDeadProfiledPages.append(std::move(page)));
|
||||
@ -3983,24 +3984,18 @@ void profiler_unregister_thread() {
|
||||
}
|
||||
}
|
||||
|
||||
void profiler_register_page(const nsID& aDocShellId, uint32_t aHistoryId,
|
||||
const nsCString& aUrl, bool aIsSubFrame) {
|
||||
DEBUG_LOG("profiler_register_page(%s, %u, %s, %d)",
|
||||
nsIDToCString(aDocShellId).get(), aHistoryId, aUrl.get(),
|
||||
aIsSubFrame);
|
||||
void profiler_register_page(uint64_t aBrowsingContextID,
|
||||
uint64_t aInnerWindowID, const nsCString& aUrl,
|
||||
bool aIsSubFrame) {
|
||||
DEBUG_LOG("profiler_register_page(%" PRIu64 ", %" PRIu64 ", %s, %d)",
|
||||
aBrowsingContextID, aInnerWindowID, aUrl.get(), aIsSubFrame);
|
||||
|
||||
MOZ_RELEASE_ASSERT(CorePS::Exists());
|
||||
|
||||
PSAutoLock lock(gPSMutex);
|
||||
|
||||
// If profiler is not active, delete all the previous page entries of the
|
||||
// given DocShell since we won't need those.
|
||||
if (!ActivePS::Exists(lock)) {
|
||||
CorePS::RemoveRegisteredPages(lock, aDocShellId);
|
||||
}
|
||||
|
||||
RefPtr<PageInformation> pageInfo =
|
||||
new PageInformation(aDocShellId, aHistoryId, aUrl, aIsSubFrame);
|
||||
RefPtr<PageInformation> pageInfo = new PageInformation(
|
||||
aBrowsingContextID, aInnerWindowID, aUrl, aIsSubFrame);
|
||||
CorePS::AppendRegisteredPage(lock, std::move(pageInfo));
|
||||
|
||||
// After appending the given page to CorePS, look for the expired
|
||||
@ -4010,7 +4005,7 @@ void profiler_register_page(const nsID& aDocShellId, uint32_t aHistoryId,
|
||||
}
|
||||
}
|
||||
|
||||
void profiler_unregister_pages(const nsID& aRegisteredDocShellId) {
|
||||
void profiler_unregister_page(uint64_t aRegisteredInnerWindowID) {
|
||||
PSAutoLock lock(gPSMutex);
|
||||
|
||||
if (!CorePS::Exists()) {
|
||||
@ -4023,9 +4018,9 @@ void profiler_unregister_pages(const nsID& aRegisteredDocShellId) {
|
||||
// page. But if profiler is not active. we have no reason to keep the
|
||||
// page information here because there can't be any marker associated with it.
|
||||
if (ActivePS::Exists(lock)) {
|
||||
ActivePS::UnregisterPages(lock, aRegisteredDocShellId);
|
||||
ActivePS::UnregisterPage(lock, aRegisteredInnerWindowID);
|
||||
} else {
|
||||
CorePS::RemoveRegisteredPages(lock, aRegisteredDocShellId);
|
||||
CorePS::RemoveRegisteredPage(lock, aRegisteredInnerWindowID);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4049,6 +4044,21 @@ void profiler_clear_all_pages() {
|
||||
ProfilerParent::ClearAllPages();
|
||||
}
|
||||
|
||||
Maybe<uint64_t> profiler_get_inner_window_id_from_docshell(
|
||||
nsIDocShell* aDocshell) {
|
||||
Maybe<uint64_t> innerWindowID = Nothing();
|
||||
if (aDocshell) {
|
||||
auto outerWindow = aDocshell->GetWindow();
|
||||
if (outerWindow) {
|
||||
auto innerWindow = outerWindow->GetCurrentInnerWindow();
|
||||
if (innerWindow) {
|
||||
innerWindowID = Some(innerWindow->WindowID());
|
||||
}
|
||||
}
|
||||
}
|
||||
return innerWindowID;
|
||||
}
|
||||
|
||||
void profiler_thread_sleep() {
|
||||
// This function runs both on and off the main thread.
|
||||
|
||||
@ -4312,8 +4322,8 @@ void profiler_add_marker_for_thread(int aThreadId,
|
||||
|
||||
void profiler_tracing(const char* aCategoryString, const char* aMarkerName,
|
||||
JS::ProfilingCategoryPair aCategoryPair,
|
||||
TracingKind aKind, const Maybe<nsID>& aDocShellId,
|
||||
const Maybe<uint32_t>& aDocShellHistoryId) {
|
||||
TracingKind aKind,
|
||||
const Maybe<uint64_t>& aInnerWindowID) {
|
||||
MOZ_RELEASE_ASSERT(CorePS::Exists());
|
||||
|
||||
VTUNE_TRACING(aMarkerName, aKind);
|
||||
@ -4324,16 +4334,15 @@ void profiler_tracing(const char* aCategoryString, const char* aMarkerName,
|
||||
}
|
||||
|
||||
AUTO_PROFILER_STATS(add_marker_with_TracingMarkerPayload);
|
||||
profiler_add_marker(aMarkerName, aCategoryPair,
|
||||
TracingMarkerPayload(aCategoryString, aKind, aDocShellId,
|
||||
aDocShellHistoryId));
|
||||
profiler_add_marker(
|
||||
aMarkerName, aCategoryPair,
|
||||
TracingMarkerPayload(aCategoryString, aKind, aInnerWindowID));
|
||||
}
|
||||
|
||||
void profiler_tracing(const char* aCategoryString, const char* aMarkerName,
|
||||
JS::ProfilingCategoryPair aCategoryPair,
|
||||
TracingKind aKind, UniqueProfilerBacktrace aCause,
|
||||
const Maybe<nsID>& aDocShellId,
|
||||
const Maybe<uint32_t>& aDocShellHistoryId) {
|
||||
const Maybe<uint64_t>& aInnerWindowID) {
|
||||
MOZ_RELEASE_ASSERT(CorePS::Exists());
|
||||
|
||||
VTUNE_TRACING(aMarkerName, aKind);
|
||||
@ -4343,25 +4352,21 @@ void profiler_tracing(const char* aCategoryString, const char* aMarkerName,
|
||||
return;
|
||||
}
|
||||
|
||||
AUTO_PROFILER_STATS(add_marker_with_TracingMarkerPayload);
|
||||
profiler_add_marker(
|
||||
aMarkerName, aCategoryPair,
|
||||
TracingMarkerPayload(aCategoryString, aKind, aDocShellId,
|
||||
aDocShellHistoryId, std::move(aCause)));
|
||||
profiler_add_marker(aMarkerName, aCategoryPair,
|
||||
TracingMarkerPayload(aCategoryString, aKind,
|
||||
aInnerWindowID, std::move(aCause)));
|
||||
}
|
||||
|
||||
void profiler_add_text_marker(
|
||||
const char* aMarkerName, const nsACString& aText,
|
||||
JS::ProfilingCategoryPair aCategoryPair,
|
||||
const mozilla::TimeStamp& aStartTime, const mozilla::TimeStamp& aEndTime,
|
||||
const mozilla::Maybe<nsID>& aDocShellId,
|
||||
const mozilla::Maybe<uint32_t>& aDocShellHistoryId,
|
||||
UniqueProfilerBacktrace aCause) {
|
||||
void profiler_add_text_marker(const char* aMarkerName, const nsACString& aText,
|
||||
JS::ProfilingCategoryPair aCategoryPair,
|
||||
const mozilla::TimeStamp& aStartTime,
|
||||
const mozilla::TimeStamp& aEndTime,
|
||||
const mozilla::Maybe<uint64_t>& aInnerWindowID,
|
||||
UniqueProfilerBacktrace aCause) {
|
||||
AUTO_PROFILER_STATS(add_marker_with_TextMarkerPayload);
|
||||
profiler_add_marker(
|
||||
aMarkerName, aCategoryPair,
|
||||
TextMarkerPayload(aText, aStartTime, aEndTime, aDocShellId,
|
||||
aDocShellHistoryId, std::move(aCause)));
|
||||
profiler_add_marker(aMarkerName, aCategoryPair,
|
||||
TextMarkerPayload(aText, aStartTime, aEndTime,
|
||||
aInnerWindowID, std::move(aCause)));
|
||||
}
|
||||
|
||||
void profiler_set_js_context(JSContext* aCx) {
|
||||
|
@ -58,7 +58,6 @@
|
||||
# define PROFILER_ADD_NETWORK_MARKER(uri, pri, channel, type, start, end, \
|
||||
count, cache, timings, redirect, ...)
|
||||
|
||||
# define DECLARE_DOCSHELL_AND_HISTORY_ID(docShell)
|
||||
# define PROFILER_TRACING(categoryString, markerName, categoryPair, kind)
|
||||
# define PROFILER_TRACING_DOCSHELL(categoryString, markerName, categoryPair, \
|
||||
kind, docshell)
|
||||
@ -95,7 +94,6 @@ static inline UniqueProfilerBacktrace profiler_get_backtrace() {
|
||||
# include "mozilla/TimeStamp.h"
|
||||
# include "mozilla/UniquePtr.h"
|
||||
# include "nscore.h"
|
||||
# include "nsID.h"
|
||||
# include "nsString.h"
|
||||
|
||||
# include <stdint.h>
|
||||
@ -111,6 +109,7 @@ enum CacheDisposition : uint8_t;
|
||||
} // namespace net
|
||||
} // namespace mozilla
|
||||
class nsIURI;
|
||||
class nsIDocShell;
|
||||
|
||||
namespace mozilla {
|
||||
class MallocAllocPolicy;
|
||||
@ -356,30 +355,30 @@ void profiler_ensure_started(
|
||||
ProfilingStack* profiler_register_thread(const char* name, void* guessStackTop);
|
||||
void profiler_unregister_thread();
|
||||
|
||||
// Register pages with the profiler.
|
||||
// Registers a DOM Window (the JS global `window`) with the profiler. Each
|
||||
// Window _roughly_ corresponds to a single document loaded within a
|
||||
// BrowsingContext. The unique IDs for both the Window and BrowsingContext are
|
||||
// recorded to allow correlating different Windows loaded within the same tab or
|
||||
// frame element.
|
||||
//
|
||||
// The `page` means every new history entry for docShells.
|
||||
// DocShellId + HistoryID is a unique pair to identify these pages.
|
||||
// We also keep these pairs inside markers to associate with the pages.
|
||||
// That allows us to see which markers belong to a specific page and filter the
|
||||
// markers by a page.
|
||||
// We register pages in these cases:
|
||||
// - If there is a navigation through a link or URL bar.
|
||||
// - If there is a navigation through `location.replace` or `history.pushState`.
|
||||
// We do not register pages in these cases:
|
||||
// - If there is a history navigation through the back and forward buttons.
|
||||
// - If there is a navigation through `history.replaceState` or anchor scrolls.
|
||||
// We register pages for each navigations but we do not register
|
||||
// history.pushState or history.replaceState since they correspond to the same
|
||||
// Inner Window ID.
|
||||
//
|
||||
// "aDocShellId" is the ID of the docShell that page belongs to.
|
||||
// "aHistoryId" is the ID of the history entry on the given docShell.
|
||||
// "aUrl" is the URL of the page.
|
||||
// "aIsSubFrame" is true if the page is a sub frame.
|
||||
void profiler_register_page(const nsID& aDocShellId, uint32_t aHistoryId,
|
||||
const nsCString& aUrl, bool aIsSubFrame);
|
||||
// Unregister pages with the profiler.
|
||||
// "aBrowsingContextID" is the ID of the browsing context that document
|
||||
// belongs to. That's used to determine the tab of that
|
||||
// page.
|
||||
// "aInnerWindowID" is the ID of the `window` global object of that
|
||||
// document.
|
||||
// "aUrl" is the URL of the page.
|
||||
// "aIsSubFrame" is true if the page is a sub frame.
|
||||
void profiler_register_page(uint64_t aBrowsingContextID,
|
||||
uint64_t aInnerWindowID, const nsCString& aUrl,
|
||||
bool aIsSubFrame);
|
||||
// Unregister page with the profiler.
|
||||
//
|
||||
// Take a docShellId and unregister all the page entries that have the given ID.
|
||||
void profiler_unregister_pages(const nsID& aRegisteredDocShellId);
|
||||
// Take a Inner Window ID and unregister the page entry that has the same ID.
|
||||
void profiler_unregister_page(uint64_t aRegisteredInnerWindowID);
|
||||
|
||||
// Remove all registered and unregistered pages in the profiler.
|
||||
void profiler_clear_all_pages();
|
||||
@ -774,23 +773,13 @@ enum TracingKind {
|
||||
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 = mozilla::Some(docShell->HistoryID()); \
|
||||
uint32_t id; \
|
||||
nsresult rv = docShell->GetOSHEId(&id); \
|
||||
if (NS_SUCCEEDED(rv)) { \
|
||||
docShellHistoryId = mozilla::Some(id); \
|
||||
} else { \
|
||||
docShellHistoryId = mozilla::Nothing(); \
|
||||
} \
|
||||
} else { \
|
||||
docShellId = mozilla::Nothing(); \
|
||||
docShellHistoryId = mozilla::Nothing(); \
|
||||
}
|
||||
// This is a helper function to get the Inner Window ID from DocShell but it's
|
||||
// not a recommended method to get it and it's not encouraged to use this
|
||||
// function. If there is a computed inner window ID, `window`, or `Document`
|
||||
// available in the call site, please use them. Use this function as a last
|
||||
// resort.
|
||||
mozilla::Maybe<uint64_t> profiler_get_inner_window_id_from_docshell(
|
||||
nsIDocShell* aDocshell);
|
||||
|
||||
// Adds a tracing marker to the profile. A no-op if the profiler is inactive or
|
||||
// in privacy mode.
|
||||
@ -800,34 +789,30 @@ enum TracingKind {
|
||||
JS::ProfilingCategoryPair::categoryPair, kind)
|
||||
# define PROFILER_TRACING_DOCSHELL(categoryString, markerName, categoryPair, \
|
||||
kind, docShell) \
|
||||
DECLARE_DOCSHELL_AND_HISTORY_ID(docShell); \
|
||||
profiler_tracing(categoryString, markerName, \
|
||||
JS::ProfilingCategoryPair::categoryPair, kind, \
|
||||
docShellId, docShellHistoryId)
|
||||
profiler_get_inner_window_id_from_docshell(docShell))
|
||||
|
||||
void profiler_tracing(
|
||||
const char* aCategoryString, const char* aMarkerName,
|
||||
JS::ProfilingCategoryPair aCategoryPair, TracingKind aKind,
|
||||
const mozilla::Maybe<nsID>& aDocShellId = mozilla::Nothing(),
|
||||
const mozilla::Maybe<uint32_t>& aDocShellHistoryId = mozilla::Nothing());
|
||||
const mozilla::Maybe<uint64_t>& aInnerWindowID = mozilla::Nothing());
|
||||
void profiler_tracing(
|
||||
const char* aCategoryString, const char* aMarkerName,
|
||||
JS::ProfilingCategoryPair aCategoryPair, TracingKind aKind,
|
||||
UniqueProfilerBacktrace aCause,
|
||||
const mozilla::Maybe<nsID>& aDocShellId = mozilla::Nothing(),
|
||||
const mozilla::Maybe<uint32_t>& aDocShellHistoryId = mozilla::Nothing());
|
||||
const mozilla::Maybe<uint64_t>& aInnerWindowID = mozilla::Nothing());
|
||||
|
||||
// Adds a START/END pair of tracing markers.
|
||||
# define AUTO_PROFILER_TRACING(categoryString, markerName, categoryPair) \
|
||||
mozilla::AutoProfilerTracing PROFILER_RAII( \
|
||||
categoryString, markerName, JS::ProfilingCategoryPair::categoryPair, \
|
||||
mozilla::Nothing(), mozilla::Nothing())
|
||||
mozilla::Nothing())
|
||||
# define AUTO_PROFILER_TRACING_DOCSHELL(categoryString, markerName, \
|
||||
categoryPair, docShell) \
|
||||
DECLARE_DOCSHELL_AND_HISTORY_ID(docShell); \
|
||||
mozilla::AutoProfilerTracing PROFILER_RAII( \
|
||||
categoryString, markerName, JS::ProfilingCategoryPair::categoryPair, \
|
||||
docShellId, docShellHistoryId)
|
||||
profiler_get_inner_window_id_from_docshell(docShell))
|
||||
|
||||
// Add a text marker. Text markers are similar to tracing markers, with the
|
||||
// difference that text markers have their "text" separate from the marker name;
|
||||
@ -839,16 +824,14 @@ void profiler_add_text_marker(
|
||||
const char* aMarkerName, const nsACString& aText,
|
||||
JS::ProfilingCategoryPair aCategoryPair,
|
||||
const mozilla::TimeStamp& aStartTime, const mozilla::TimeStamp& aEndTime,
|
||||
const mozilla::Maybe<nsID>& aDocShellId = mozilla::Nothing(),
|
||||
const mozilla::Maybe<uint32_t>& aDocShellHistoryId = mozilla::Nothing(),
|
||||
const mozilla::Maybe<uint64_t>& aInnerWindowID = mozilla::Nothing(),
|
||||
UniqueProfilerBacktrace aCause = nullptr);
|
||||
|
||||
class MOZ_RAII AutoProfilerTextMarker {
|
||||
public:
|
||||
AutoProfilerTextMarker(const char* aMarkerName, const nsACString& aText,
|
||||
JS::ProfilingCategoryPair aCategoryPair,
|
||||
const mozilla::Maybe<nsID>& aDocShellId,
|
||||
const mozilla::Maybe<uint32_t>& aDocShellHistoryId,
|
||||
const mozilla::Maybe<uint64_t>& aInnerWindowID,
|
||||
UniqueProfilerBacktrace&& aCause =
|
||||
nullptr MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: mMarkerName(aMarkerName),
|
||||
@ -856,15 +839,14 @@ class MOZ_RAII AutoProfilerTextMarker {
|
||||
mCategoryPair(aCategoryPair),
|
||||
mStartTime(mozilla::TimeStamp::NowUnfuzzed()),
|
||||
mCause(std::move(aCause)),
|
||||
mDocShellId(aDocShellId),
|
||||
mDocShellHistoryId(aDocShellHistoryId) {
|
||||
mInnerWindowID(aInnerWindowID) {
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
}
|
||||
|
||||
~AutoProfilerTextMarker() {
|
||||
profiler_add_text_marker(mMarkerName, mText, mCategoryPair, mStartTime,
|
||||
mozilla::TimeStamp::NowUnfuzzed(), mDocShellId,
|
||||
mDocShellHistoryId, std::move(mCause));
|
||||
mozilla::TimeStamp::NowUnfuzzed(), mInnerWindowID,
|
||||
std::move(mCause));
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -874,29 +856,26 @@ class MOZ_RAII AutoProfilerTextMarker {
|
||||
const JS::ProfilingCategoryPair mCategoryPair;
|
||||
mozilla::TimeStamp mStartTime;
|
||||
UniqueProfilerBacktrace mCause;
|
||||
const mozilla::Maybe<nsID> mDocShellId;
|
||||
const mozilla::Maybe<uint32_t> mDocShellHistoryId;
|
||||
const mozilla::Maybe<uint64_t> mInnerWindowID;
|
||||
};
|
||||
|
||||
# define AUTO_PROFILER_TEXT_MARKER_CAUSE(markerName, text, categoryPair, \
|
||||
cause) \
|
||||
AutoProfilerTextMarker PROFILER_RAII( \
|
||||
markerName, text, JS::ProfilingCategoryPair::categoryPair, \
|
||||
mozilla::Nothing(), mozilla::Nothing(), cause)
|
||||
mozilla::Nothing(), cause)
|
||||
|
||||
# define AUTO_PROFILER_TEXT_MARKER_DOCSHELL(markerName, text, categoryPair, \
|
||||
docShell) \
|
||||
DECLARE_DOCSHELL_AND_HISTORY_ID(docShell); \
|
||||
AutoProfilerTextMarker PROFILER_RAII( \
|
||||
markerName, text, JS::ProfilingCategoryPair::categoryPair, docShellId, \
|
||||
docShellHistoryId)
|
||||
# define AUTO_PROFILER_TEXT_MARKER_DOCSHELL(markerName, text, categoryPair, \
|
||||
docShell) \
|
||||
AutoProfilerTextMarker PROFILER_RAII( \
|
||||
markerName, text, JS::ProfilingCategoryPair::categoryPair, \
|
||||
profiler_get_inner_window_id_from_docshell(docShell))
|
||||
|
||||
# define AUTO_PROFILER_TEXT_MARKER_DOCSHELL_CAUSE( \
|
||||
markerName, text, categoryPair, docShell, cause) \
|
||||
DECLARE_DOCSHELL_AND_HISTORY_ID(docShell); \
|
||||
AutoProfilerTextMarker PROFILER_RAII( \
|
||||
markerName, text, JS::ProfilingCategoryPair::categoryPair, docShellId, \
|
||||
docShellHistoryId, cause)
|
||||
# define AUTO_PROFILER_TEXT_MARKER_DOCSHELL_CAUSE( \
|
||||
markerName, text, categoryPair, docShell, cause) \
|
||||
AutoProfilerTextMarker PROFILER_RAII( \
|
||||
markerName, text, JS::ProfilingCategoryPair::categoryPair, \
|
||||
profiler_get_inner_window_id_from_docshell(docShell), cause)
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Output profiles
|
||||
@ -1068,39 +1047,35 @@ class MOZ_RAII AutoProfilerTracing {
|
||||
public:
|
||||
AutoProfilerTracing(const char* aCategoryString, const char* aMarkerName,
|
||||
JS::ProfilingCategoryPair aCategoryPair,
|
||||
const mozilla::Maybe<nsID>& aDocShellId,
|
||||
const mozilla::Maybe<uint32_t>& aDocShellHistoryId
|
||||
const mozilla::Maybe<uint64_t>& aInnerWindowID
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: mCategoryString(aCategoryString),
|
||||
mMarkerName(aMarkerName),
|
||||
mCategoryPair(aCategoryPair),
|
||||
mDocShellId(aDocShellId),
|
||||
mDocShellHistoryId(aDocShellHistoryId) {
|
||||
mInnerWindowID(aInnerWindowID) {
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
profiler_tracing(mCategoryString, mMarkerName, aCategoryPair,
|
||||
TRACING_INTERVAL_START, mDocShellId, mDocShellHistoryId);
|
||||
TRACING_INTERVAL_START, mInnerWindowID);
|
||||
}
|
||||
|
||||
AutoProfilerTracing(const char* aCategoryString, const char* aMarkerName,
|
||||
JS::ProfilingCategoryPair aCategoryPair,
|
||||
UniqueProfilerBacktrace aBacktrace,
|
||||
const mozilla::Maybe<nsID>& aDocShellId,
|
||||
const mozilla::Maybe<uint32_t>& aDocShellHistoryId
|
||||
const mozilla::Maybe<uint64_t>& aInnerWindowID
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: mCategoryString(aCategoryString),
|
||||
mMarkerName(aMarkerName),
|
||||
mCategoryPair(aCategoryPair),
|
||||
mDocShellId(aDocShellId),
|
||||
mDocShellHistoryId(aDocShellHistoryId) {
|
||||
mInnerWindowID(aInnerWindowID) {
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
profiler_tracing(mCategoryString, mMarkerName, aCategoryPair,
|
||||
TRACING_INTERVAL_START, std::move(aBacktrace), mDocShellId,
|
||||
mDocShellHistoryId);
|
||||
TRACING_INTERVAL_START, std::move(aBacktrace),
|
||||
mInnerWindowID);
|
||||
}
|
||||
|
||||
~AutoProfilerTracing() {
|
||||
profiler_tracing(mCategoryString, mMarkerName, mCategoryPair,
|
||||
TRACING_INTERVAL_END, mDocShellId, mDocShellHistoryId);
|
||||
TRACING_INTERVAL_END, mInnerWindowID);
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -1108,8 +1083,7 @@ class MOZ_RAII AutoProfilerTracing {
|
||||
const char* mCategoryString;
|
||||
const char* mMarkerName;
|
||||
const JS::ProfilingCategoryPair mCategoryPair;
|
||||
const mozilla::Maybe<nsID> mDocShellId;
|
||||
const mozilla::Maybe<uint32_t> mDocShellHistoryId;
|
||||
const mozilla::Maybe<uint64_t> mInnerWindowID;
|
||||
};
|
||||
|
||||
// Get the MOZ_PROFILER_STARTUP* environment variables that should be
|
||||
|
@ -45,20 +45,16 @@ class UniqueStacks;
|
||||
class ProfilerMarkerPayload {
|
||||
public:
|
||||
explicit ProfilerMarkerPayload(
|
||||
const mozilla::Maybe<nsID>& aDocShellId = mozilla::Nothing(),
|
||||
const mozilla::Maybe<uint32_t>& aDocShellHistoryId = mozilla::Nothing(),
|
||||
const mozilla::Maybe<uint64_t>& aInnerWindowID = mozilla::Nothing(),
|
||||
UniqueProfilerBacktrace aStack = nullptr)
|
||||
: mCommonProps{mozilla::TimeStamp{}, mozilla::TimeStamp{},
|
||||
std::move(aStack), std::move(aDocShellId),
|
||||
std::move(aDocShellHistoryId)} {}
|
||||
std::move(aStack), aInnerWindowID} {}
|
||||
|
||||
ProfilerMarkerPayload(
|
||||
const mozilla::TimeStamp& aStartTime, const mozilla::TimeStamp& aEndTime,
|
||||
const mozilla::Maybe<nsID>& aDocShellId = mozilla::Nothing(),
|
||||
const mozilla::Maybe<uint32_t>& aDocShellHistoryId = mozilla::Nothing(),
|
||||
const mozilla::Maybe<uint64_t>& aInnerWindowID = mozilla::Nothing(),
|
||||
UniqueProfilerBacktrace aStack = nullptr)
|
||||
: mCommonProps{aStartTime, aEndTime, std::move(aStack),
|
||||
std::move(aDocShellId), std::move(aDocShellHistoryId)} {}
|
||||
: mCommonProps{aStartTime, aEndTime, std::move(aStack), aInnerWindowID} {}
|
||||
|
||||
virtual ~ProfilerMarkerPayload() {}
|
||||
|
||||
@ -141,8 +137,7 @@ class ProfilerMarkerPayload {
|
||||
mozilla::TimeStamp mStartTime;
|
||||
mozilla::TimeStamp mEndTime;
|
||||
UniqueProfilerBacktrace mStack;
|
||||
mozilla::Maybe<nsID> mDocShellId;
|
||||
mozilla::Maybe<uint32_t> mDocShellHistoryId;
|
||||
mozilla::Maybe<uint64_t> mInnerWindowID;
|
||||
};
|
||||
|
||||
// Deserializers can use this base constructor.
|
||||
@ -187,17 +182,15 @@ class ProfilerMarkerPayload {
|
||||
void SerializeTagAndPayload( \
|
||||
mozilla::BlocksRingBuffer::EntryWriter& aEntryWriter) const override;
|
||||
|
||||
// TODO: Increase the coverage of tracing markers that include DocShell
|
||||
// TODO: Increase the coverage of tracing markers that include InnerWindowID
|
||||
// information
|
||||
class TracingMarkerPayload : public ProfilerMarkerPayload {
|
||||
public:
|
||||
TracingMarkerPayload(
|
||||
const char* aCategory, TracingKind aKind,
|
||||
const mozilla::Maybe<nsID>& aDocShellId = mozilla::Nothing(),
|
||||
const mozilla::Maybe<uint32_t>& aDocShellHistoryId = mozilla::Nothing(),
|
||||
const mozilla::Maybe<uint64_t>& aInnerWindowID = mozilla::Nothing(),
|
||||
UniqueProfilerBacktrace aCause = nullptr)
|
||||
: ProfilerMarkerPayload(aDocShellId, aDocShellHistoryId,
|
||||
std::move(aCause)),
|
||||
: ProfilerMarkerPayload(aInnerWindowID, std::move(aCause)),
|
||||
mCategory(aCategory),
|
||||
mKind(aKind) {}
|
||||
|
||||
@ -228,7 +221,7 @@ class FileIOMarkerPayload : public ProfilerMarkerPayload {
|
||||
const mozilla::TimeStamp& aEndTime,
|
||||
UniqueProfilerBacktrace aStack)
|
||||
: ProfilerMarkerPayload(aStartTime, aEndTime, mozilla::Nothing(),
|
||||
mozilla::Nothing(), std::move(aStack)),
|
||||
std::move(aStack)),
|
||||
mSource(aSource),
|
||||
mOperation(aOperation ? strdup(aOperation) : nullptr),
|
||||
mFilename(aFilename ? strdup(aFilename) : nullptr) {
|
||||
@ -256,9 +249,8 @@ class DOMEventMarkerPayload : public TracingMarkerPayload {
|
||||
DOMEventMarkerPayload(const nsAString& aEventType,
|
||||
const mozilla::TimeStamp& aTimeStamp,
|
||||
const char* aCategory, TracingKind aKind,
|
||||
const mozilla::Maybe<nsID>& aDocShellId,
|
||||
const mozilla::Maybe<uint32_t>& aDocShellHistoryId)
|
||||
: TracingMarkerPayload(aCategory, aKind, aDocShellId, aDocShellHistoryId),
|
||||
const mozilla::Maybe<uint64_t>& aInnerWindowID)
|
||||
: TracingMarkerPayload(aCategory, aKind, aInnerWindowID),
|
||||
mTimeStamp(aTimeStamp),
|
||||
mEventType(aEventType) {}
|
||||
|
||||
@ -321,10 +313,8 @@ class UserTimingMarkerPayload : public ProfilerMarkerPayload {
|
||||
public:
|
||||
UserTimingMarkerPayload(const nsAString& aName,
|
||||
const mozilla::TimeStamp& aStartTime,
|
||||
const mozilla::Maybe<nsID>& aDocShellId,
|
||||
const mozilla::Maybe<uint32_t>& aDocShellHistoryId)
|
||||
: ProfilerMarkerPayload(aStartTime, aStartTime, aDocShellId,
|
||||
aDocShellHistoryId),
|
||||
const mozilla::Maybe<uint64_t>& aInnerWindowID)
|
||||
: ProfilerMarkerPayload(aStartTime, aStartTime, aInnerWindowID),
|
||||
mEntryType("mark"),
|
||||
mName(aName) {}
|
||||
|
||||
@ -333,10 +323,8 @@ class UserTimingMarkerPayload : public ProfilerMarkerPayload {
|
||||
const mozilla::Maybe<nsString>& aEndMark,
|
||||
const mozilla::TimeStamp& aStartTime,
|
||||
const mozilla::TimeStamp& aEndTime,
|
||||
const mozilla::Maybe<nsID>& aDocShellId,
|
||||
const mozilla::Maybe<uint32_t>& aDocShellHistoryId)
|
||||
: ProfilerMarkerPayload(aStartTime, aEndTime, aDocShellId,
|
||||
aDocShellHistoryId),
|
||||
const mozilla::Maybe<uint64_t>& aInnerWindowID)
|
||||
: ProfilerMarkerPayload(aStartTime, aEndTime, aInnerWindowID),
|
||||
mEntryType("measure"),
|
||||
mName(aName),
|
||||
mStartMark(aStartMark),
|
||||
@ -413,7 +401,7 @@ class NetworkMarkerPayload : public ProfilerMarkerPayload {
|
||||
const char* aRedirectURI = nullptr,
|
||||
UniqueProfilerBacktrace aSource = nullptr)
|
||||
: ProfilerMarkerPayload(aStartTime, aEndTime, mozilla::Nothing(),
|
||||
mozilla::Nothing(), std::move(aSource)),
|
||||
std::move(aSource)),
|
||||
mID(aID),
|
||||
mURI(aURI ? strdup(aURI) : nullptr),
|
||||
mRedirectURI(aRedirectURI && (strlen(aRedirectURI) > 0)
|
||||
@ -559,10 +547,9 @@ class StyleMarkerPayload : public ProfilerMarkerPayload {
|
||||
const mozilla::TimeStamp& aEndTime,
|
||||
UniqueProfilerBacktrace aCause,
|
||||
const mozilla::ServoTraversalStatistics& aStats,
|
||||
const mozilla::Maybe<nsID>& aDocShellId,
|
||||
const mozilla::Maybe<uint32_t>& aDocShellHistoryId)
|
||||
: ProfilerMarkerPayload(aStartTime, aEndTime, aDocShellId,
|
||||
aDocShellHistoryId, std::move(aCause)),
|
||||
const mozilla::Maybe<uint64_t>& aInnerWindowID)
|
||||
: ProfilerMarkerPayload(aStartTime, aEndTime, aInnerWindowID,
|
||||
std::move(aCause)),
|
||||
mStats(aStats) {}
|
||||
|
||||
DECL_STREAM_PAYLOAD
|
||||
@ -601,20 +588,17 @@ class TextMarkerPayload : public ProfilerMarkerPayload {
|
||||
|
||||
TextMarkerPayload(const nsACString& aText,
|
||||
const mozilla::TimeStamp& aStartTime,
|
||||
const mozilla::Maybe<nsID>& aDocShellId,
|
||||
const mozilla::Maybe<uint32_t>& aDocShellHistoryId)
|
||||
: ProfilerMarkerPayload(aStartTime, aStartTime, aDocShellId,
|
||||
aDocShellHistoryId),
|
||||
const mozilla::Maybe<uint64_t>& aInnerWindowID)
|
||||
: ProfilerMarkerPayload(aStartTime, aStartTime, aInnerWindowID),
|
||||
mText(aText) {}
|
||||
|
||||
TextMarkerPayload(const nsACString& aText,
|
||||
const mozilla::TimeStamp& aStartTime,
|
||||
const mozilla::TimeStamp& aEndTime,
|
||||
const mozilla::Maybe<nsID>& aDocShellId,
|
||||
const mozilla::Maybe<uint32_t>& aDocShellHistoryId,
|
||||
const mozilla::Maybe<uint64_t>& aInnerWindowID,
|
||||
UniqueProfilerBacktrace aCause = nullptr)
|
||||
: ProfilerMarkerPayload(aStartTime, aEndTime, aDocShellId,
|
||||
aDocShellHistoryId, std::move(aCause)),
|
||||
: ProfilerMarkerPayload(aStartTime, aEndTime, aInnerWindowID,
|
||||
std::move(aCause)),
|
||||
mText(aText) {}
|
||||
|
||||
DECL_STREAM_PAYLOAD
|
||||
@ -654,7 +638,7 @@ class JsAllocationMarkerPayload : public ProfilerMarkerPayload {
|
||||
JS::RecordAllocationInfo&& aInfo,
|
||||
UniqueProfilerBacktrace aStack)
|
||||
: ProfilerMarkerPayload(aStartTime, aStartTime, mozilla::Nothing(),
|
||||
mozilla::Nothing(), std::move(aStack)),
|
||||
std::move(aStack)),
|
||||
// Copy the strings, and take ownership of them.
|
||||
mTypeName(aInfo.typeName ? NS_xstrdup(aInfo.typeName) : nullptr),
|
||||
mClassName(aInfo.className ? strdup(aInfo.className) : nullptr),
|
||||
@ -706,7 +690,7 @@ class NativeAllocationMarkerPayload : public ProfilerMarkerPayload {
|
||||
const int64_t aSize,
|
||||
UniqueProfilerBacktrace aStack)
|
||||
: ProfilerMarkerPayload(aStartTime, aStartTime, mozilla::Nothing(),
|
||||
mozilla::Nothing(), std::move(aStack)),
|
||||
std::move(aStack)),
|
||||
mSize(aSize) {}
|
||||
|
||||
DECL_STREAM_PAYLOAD
|
||||
|
@ -12,6 +12,11 @@ support-files =
|
||||
[browser_test_feature_preferencereads.js]
|
||||
[browser_test_feature_nativeallocations.js]
|
||||
[browser_test_profile_single_frame_page_info.js]
|
||||
skip-if = true # Bug 1583271 - Temporarily disabling it
|
||||
[browser_test_profile_multi_frame_page_info.js]
|
||||
skip-if = true # Bug 1583271 - Temporarily disabling it
|
||||
[browser_test_profile_pushstate_page_info.js]
|
||||
skip-if = true # Bug 1583271 - Temporarily disabling it
|
||||
[browser_test_profile_replacestate_page_info.js]
|
||||
skip-if = true # Bug 1583271 - Temporarily disabling it
|
||||
|
||||
|
@ -599,8 +599,7 @@ TEST(GeckoProfiler, Markers)
|
||||
PROFILER_ADD_MARKER("M3", OTHER);
|
||||
PROFILER_ADD_MARKER_WITH_PAYLOAD(
|
||||
"M4", OTHER, TracingMarkerPayload,
|
||||
("C", TRACING_EVENT, mozilla::Nothing(), mozilla::Nothing(),
|
||||
profiler_get_backtrace()));
|
||||
("C", TRACING_EVENT, mozilla::Nothing(), profiler_get_backtrace()));
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
PROFILER_ADD_MARKER_WITH_PAYLOAD("M5", OTHER, GTestMarkerPayload, (i));
|
||||
@ -659,7 +658,7 @@ TEST(GeckoProfiler, Markers)
|
||||
PROFILER_ADD_MARKER_WITH_PAYLOAD(
|
||||
"DOMEventMarkerPayload marker", OTHER, DOMEventMarkerPayload,
|
||||
(NS_LITERAL_STRING("dom event"), ts1, "category", TRACING_EVENT,
|
||||
mozilla::Nothing(), mozilla::Nothing()));
|
||||
mozilla::Nothing()));
|
||||
|
||||
{
|
||||
const char gcMajorJSON[] = "42";
|
||||
@ -729,16 +728,14 @@ TEST(GeckoProfiler, Markers)
|
||||
TextMarkerPayload,
|
||||
(NS_LITERAL_CSTRING("text"), ts1, ts2));
|
||||
|
||||
PROFILER_ADD_MARKER_WITH_PAYLOAD("UserTimingMarkerPayload marker mark", OTHER,
|
||||
UserTimingMarkerPayload,
|
||||
(NS_LITERAL_STRING("mark name"), ts1,
|
||||
mozilla::Nothing(), mozilla::Nothing()));
|
||||
PROFILER_ADD_MARKER_WITH_PAYLOAD(
|
||||
"UserTimingMarkerPayload marker mark", OTHER, UserTimingMarkerPayload,
|
||||
(NS_LITERAL_STRING("mark name"), ts1, mozilla::Nothing()));
|
||||
|
||||
PROFILER_ADD_MARKER_WITH_PAYLOAD(
|
||||
"UserTimingMarkerPayload marker measure", OTHER, UserTimingMarkerPayload,
|
||||
(NS_LITERAL_STRING("measure name"), Some(NS_LITERAL_STRING("start mark")),
|
||||
Some(NS_LITERAL_STRING("end mark")), ts1, ts2, mozilla::Nothing(),
|
||||
mozilla::Nothing()));
|
||||
Some(NS_LITERAL_STRING("end mark")), ts1, ts2, mozilla::Nothing()));
|
||||
|
||||
PROFILER_ADD_MARKER_WITH_PAYLOAD("VsyncMarkerPayload marker", OTHER,
|
||||
VsyncMarkerPayload, (ts1));
|
||||
|
Loading…
Reference in New Issue
Block a user