Closed
Bug 1443443
Opened 6 years ago
Closed 6 years ago
Extend PContent to retrieve Performance Counters in the parent process
Categories
(Core :: DOM: Content Processes, defect, P3)
Tracking
()
RESOLVED
FIXED
mozilla61
Tracking | Status | |
---|---|---|
firefox61 | --- | fixed |
People
(Reporter: tarek, Assigned: tarek)
References
Details
(Whiteboard: [perf-tools])
Attachments
(1 file)
Extends the PContent protocol so the parent process can retrieve performance counter values from all DocGroup and Workers (see Bug 1439929 and 1437438)
Comment hidden (mozreview-request) |
Comment 2•6 years ago
|
||
mozreview-review |
Comment on attachment 8956757 [details] Bug 1443443 - Extend PContent to retrieve Performance Counters in the parent process - https://reviewboard.mozilla.org/r/225726/#review231580 This works for e10s, what about non e10s? ::: dom/base/DocGroup.cpp:10 (Diff revision 1) > * You can obtain one at http://mozilla.org/MPL/2.0/. */ > > +#include <unistd.h> // for getpid() > #include "mozilla/dom/DocGroup.h" > #include "mozilla/dom/TabGroup.h" > +#include "mozilla/dom/DOMTypes.h" alphabetic order. ::: dom/base/DocGroup.cpp:18 (Diff revision 1) > #include "nsDOMMutationObserver.h" > > namespace mozilla { > namespace dom { > > + no extra line. ::: dom/base/DocGroup.cpp:89 (Diff revision 1) > + uint16_t count = 0; > + uint64_t duration = 0; > + nsCString host = NS_LITERAL_CSTRING("None"); > + > + // XXX cache ? > + for (const auto& _doc : *this) { why _doc and not doc ? Call it document instead. ::: dom/base/DocGroup.cpp:91 (Diff revision 1) > + nsCString host = NS_LITERAL_CSTRING("None"); > + > + // XXX cache ? > + for (const auto& _doc : *this) { > + // grabbing the host name of the first document > + nsCOMPtr<nsIDocument> doc = do_QueryInterface(_doc); MOZ_ASSERT(doc) ::: dom/base/DocGroup.cpp:93 (Diff revision 1) > + // XXX cache ? > + for (const auto& _doc : *this) { > + // grabbing the host name of the first document > + nsCOMPtr<nsIDocument> doc = do_QueryInterface(_doc); > + nsCOMPtr<nsIURI> docURI = doc->GetDocumentURI(); > + if (docURI) { quick continue. if (!docURI) {\ncontinue;\n} with indentation :) ::: dom/base/DocGroup.cpp:101 (Diff revision 1) > + pwid = wid; > + nsPIDOMWindowInner* win = doc->GetInnerWindow(); > + if (win) { > + nsPIDOMWindowOuter* outer = win->GetOuterWindow(); > + if (outer) { > + nsCOMPtr<nsPIDOMWindowOuter> top = outer->GetTop(); GetTop or GetScriptableTop? ::: dom/base/DocGroup.cpp:111 (Diff revision 1) > + } > + break; > + } > + } > + > + for (uint32_t key = 0; key < (size_t)TaskCategory::Count; key++) { why casting to size_t ? and not uint32_t? ::: dom/base/nsIPerformanceMetrics.idl:19 (Diff revision 1) > + readonly attribute unsigned long pid; > + readonly attribute unsigned long long wid; > + readonly attribute unsigned long long pwid; > + readonly attribute unsigned long count; > + readonly attribute unsigned long long duration; > + readonly attribute bool worker; please, comment each one of these attributes. It's unclear what pid/wpid/pwid are. Also count... count what? duration of what? key? ::: dom/base/nsPerformanceMetrics.cpp:19 (Diff revision 1) > +PerformanceMetricsData::PerformanceMetricsData(uint32_t aPid, uint64_t aWid, > + uint64_t aPwid, const nsCString& aHost, > + uint32_t aKey, uint32_t aCount, > + uint64_t aDuration, > + bool aWorker) > + : mPid(aPid), mWid(aWid), mPwid(aPwid), mCount(aCount), mHost(aHost), 2 spaces here and not 4. ::: dom/base/nsPerformanceMetrics.cpp:23 (Diff revision 1) > + bool aWorker) > + : mPid(aPid), mWid(aWid), mPwid(aPwid), mCount(aCount), mHost(aHost), > + mKey(aKey), mDuration(aDuration), mWorker(aWorker) > +{ > +} > + no extra line here. ::: dom/base/nsPerformanceMetrics.cpp:76 (Diff revision 1) > +{ > + *aPwid = mPwid; > + return NS_OK; > +}; > + > + no extra line here. ::: dom/base/nsPerformanceMetrics.cpp:84 (Diff revision 1) > +PerformanceMetricsData::GetCount(uint32_t* aCount) > +{ > + *aCount = mCount; > + return NS_OK; > +}; > + no extra line here. ::: dom/ipc/ContentChild.h:192 (Diff revision 1) > Endpoint<PImageBridgeChild>&& aImageBridge, > Endpoint<PVRManagerChild>&& aVRBridge, > Endpoint<PVideoDecoderManagerChild>&& aVideoManager, > nsTArray<uint32_t>&& namespaces) override; > > + virtual mozilla::ipc::IPCResult why virtual? You want: mozilla::ipc::IPCResult RecvRequestPerformanceMatrics() override; ::: dom/ipc/ContentChild.cpp:1353 (Diff revision 1) > + nsTArray<PerformanceInfo> data; > + > + // iterate on all WorkerDebugger > + RefPtr<WorkerDebuggerManager> wdm = WorkerDebuggerManager::Get(); > + > + for (size_t index = 0; index < wdm->GetDebuggersLength(); index++) { no size. uint32_t please. ::: dom/ipc/ContentChild.cpp:1354 (Diff revision 1) > + > + // iterate on all WorkerDebugger > + RefPtr<WorkerDebuggerManager> wdm = WorkerDebuggerManager::Get(); > + > + for (size_t index = 0; index < wdm->GetDebuggersLength(); index++) { > + WorkerDebugger* debugger = wdm->GetDebuggerAt(index); MOZ_ASSERT(debugger); ::: dom/ipc/ContentChild.cpp:1355 (Diff revision 1) > + // iterate on all WorkerDebugger > + RefPtr<WorkerDebuggerManager> wdm = WorkerDebuggerManager::Get(); > + > + for (size_t index = 0; index < wdm->GetDebuggersLength(); index++) { > + WorkerDebugger* debugger = wdm->GetDebuggerAt(index); > + data.AppendElement(debugger->ReportPerformanceInfo()); Can we make this nsTArray fallible? ::: dom/ipc/ContentChild.cpp:1370 (Diff revision 1) > + docGroup->ReportPerformanceInfo(&data); > + } > + } > + > + // send the array asynchronously > + ContentChild::GetSingleton()->SendAddPerformanceMetrics(data); Just do: SendAddPerformanceMatrics(data); ::: dom/ipc/ContentParent.cpp:3277 (Diff revision 1) > } > return IPC_OK(); > } > > +mozilla::ipc::IPCResult > +ContentParent::RecvAddPerformanceMetrics(nsTArray <PerformanceInfo>&& aMetrics) no extra space before < ::: dom/ipc/ContentParent.cpp:3280 (Diff revision 1) > > +mozilla::ipc::IPCResult > +ContentParent::RecvAddPerformanceMetrics(nsTArray <PerformanceInfo>&& aMetrics) > +{ > + // converting the data we get from a child as a notification > + if (aMetrics.Length() == 0) { IsEmpty() ::: dom/ipc/ContentParent.cpp:3284 (Diff revision 1) > + // converting the data we get from a child as a notification > + if (aMetrics.Length() == 0) { > + return IPC_OK(); > + } > + > + nsCOMPtr<nsIMutableArray> xpMetrics = do_CreateInstance(NS_ARRAY_CONTRACTID); if (NS_WARN_IF(!xpMatrics)) ... ::: dom/ipc/ContentParent.cpp:3287 (Diff revision 1) > + } > + > + nsCOMPtr<nsIMutableArray> xpMetrics = do_CreateInstance(NS_ARRAY_CONTRACTID); > + > + for (size_t i = 0; i<aMetrics.Length(); i++) { > + PerformanceInfo entry = aMetrics[i]; const PerformanceInfo& ::: dom/workers/WorkerDebuggerManager.h:80 (Diff revision 1) > UnregisterDebuggerMainThread(WorkerPrivate* aWorkerPrivate); > > + size_t > + GetDebuggersLength() > + { > + return mDebuggers.Length(); IsEmpty() ? ::: dom/workers/WorkerDebuggerManager.h:86 (Diff revision 1) > + } > + > + WorkerDebugger* > + GetDebuggerAt(size_t index) > + { > + return mDebuggers.ElementAt(index); 1. Use SafeElementAt()... or make MOZ_DIAGNOSTIC_ASSERT(index < mDebuggers.Length()). 2. aIndex
Attachment #8956757 -
Flags: review?(amarchesini) → review-
Assignee | ||
Comment 3•6 years ago
|
||
mozreview-review-reply |
Comment on attachment 8956757 [details] Bug 1443443 - Extend PContent to retrieve Performance Counters in the parent process - https://reviewboard.mozilla.org/r/225726/#review231580 I don't think we need to track the performances in non es10 - is there a flag I can use to deactivate the feature in non-es10 ? > GetTop or GetScriptableTop? I am not sure actually. I've looked at the difference but I am a bit confused about the impact on workers and docgroup docs > IsEmpty() ? is this issue a mistake?
Assignee | ||
Comment 4•6 years ago
|
||
mozreview-review-reply |
Comment on attachment 8956757 [details] Bug 1443443 - Extend PContent to retrieve Performance Counters in the parent process - https://reviewboard.mozilla.org/r/225726/#review231580 > Can we make this nsTArray fallible? I am not sure how to do this. the array contains IPDL class that won't allow me to copy one into another. Or I've failed to find the way.
Comment hidden (mozreview-request) |
Comment 6•6 years ago
|
||
mozreview-review |
Comment on attachment 8956757 [details] Bug 1443443 - Extend PContent to retrieve Performance Counters in the parent process - https://reviewboard.mozilla.org/r/225726/#review231960 ::: dom/base/DocGroup.cpp:87 (Diff revision 2) > + uint64_t pwid = 0; > + uint16_t count = 0; > + uint64_t duration = 0; > + nsCString host = NS_LITERAL_CSTRING("None"); > + > + // XXX cache ? What is this comment about? ::: dom/ipc/ContentChild.cpp:1351 (Diff revision 2) > +ContentChild::RecvRequestPerformanceMetrics() > +{ > + nsTArray<PerformanceInfo> data; > + > + // iterate on all WorkerDebugger > + RefPtr<WorkerDebuggerManager> wdm = WorkerDebuggerManager::Get(); if (NS_WARN_IF(!wdm)) { return IPC_OK(); } ::: dom/ipc/DOMTypes.ipdlh:131 (Diff revision 2) > * in WorkerPrivate & DocGroup instances > */ > struct PerformanceInfo > { > nsCString host; > + uint16_t category; I asked a comment about what these attributes are... It's hard to review them without knowing what pwid/wid are and so on. ::: dom/ipc/DOMTypes.ipdlh:143 (Diff revision 2) > +}; > + > +/** > + * Used to pass performance info stored > + * in WorkerPrivate & DocGroup instances > + */ There is a merge issue here... 2 performanceInfo? ::: dom/workers/WorkerDebuggerManager.h:78 (Diff revision 2) > > void > UnregisterDebuggerMainThread(WorkerPrivate* aWorkerPrivate); > > + uint32_t > + GetDebuggersLength(); GetDebuggersLength() const ::: dom/workers/WorkerDebuggerManager.h:81 (Diff revision 2) > > + uint32_t > + GetDebuggersLength(); > + > + WorkerDebugger* > + GetDebuggerAt(uint32_t aIndex); GetDebuggerAt(uint32_t aIndex) const
Attachment #8956757 -
Flags: review?(amarchesini) → review-
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment 9•6 years ago
|
||
mozreview-review |
Comment on attachment 8956757 [details] Bug 1443443 - Extend PContent to retrieve Performance Counters in the parent process - https://reviewboard.mozilla.org/r/225726/#review232014
Attachment #8956757 -
Flags: review?(amarchesini) → review+
Assignee | ||
Comment 10•6 years ago
|
||
mozreview-review-reply |
Comment on attachment 8956757 [details] Bug 1443443 - Extend PContent to retrieve Performance Counters in the parent process - https://reviewboard.mozilla.org/r/225726/#review231580 after a discussion on IRC, I will externalize the code added in ContentChild, so it can also be executed in the main process via a runnable to collect performance counters on the parent process. > I am not sure actually. I've looked at the difference but I am a bit confused about the impact on workers and docgroup docs after a discussion on IRC with baku, GetTop() is the right one to use (since I want to try to crawl back to the tab)
Comment hidden (mozreview-request) |
Updated•6 years ago
|
Priority: -- → P3
Assignee | ||
Updated•6 years ago
|
Assignee: nobody → tarek
Comment hidden (mozreview-request) |
Updated•6 years ago
|
Whiteboard: [perf-tools]
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment 17•6 years ago
|
||
mozreview-review |
Comment on attachment 8956757 [details] Bug 1443443 - Extend PContent to retrieve Performance Counters in the parent process - https://reviewboard.mozilla.org/r/225724/#review235080 ::: dom/base/ChromeUtils.cpp:660 (Diff revision 10) > #endif // NIGHTLY_BUILD > > +#ifndef RELEASE_OR_BETA > +/* static */ void > +ChromeUtils::RequestPerformanceMetrics(GlobalObject&) > +{ MOZ_ASSERT(XRE_IsParentProcess());
Comment hidden (mozreview-request) |
Comment 19•6 years ago
|
||
Pushed by tziade@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/20e9096156b0 Extend PContent to retrieve Performance Counters in the parent process - r=baku
Comment 20•6 years ago
|
||
Backed out changeset 20e9096156b0 (bug 1443443) for failing in dom/tests/browser/browser_test_performance_metrics.js on a CLOSED TREE Push with failures: https://treeherder.mozilla.org/#/jobs?repo=autoland&revision=20e9096156b084368e4adc884e5a63ea1f6ed753&filter-resultStatus=testfailed&filter-resultStatus=busted&filter-resultStatus=exception&filter-resultStatus=retry&filter-resultStatus=usercancel&filter-resultStatus=runnable&filter-resultStatus=success&filter-resultStatus=running Failure log: https://treeherder.mozilla.org/logviewer.html#?job_id=169226126&repo=autoland&lineNumber=1322 Backout: https://hg.mozilla.org/integration/autoland/rev/857451e02515b258368c5197c01aaa7b0ce63a8b
Flags: needinfo?(tarek)
Assignee | ||
Comment 21•6 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=e2325efabada0e86061062a317c460ae6a226cb6
Comment hidden (mozreview-request) |
Comment 24•6 years ago
|
||
Pushed by tziade@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/fae7d9814403 Extend PContent to retrieve Performance Counters in the parent process - r=baku
Comment 25•6 years ago
|
||
Backout by csabou@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/25ddde05fe9a Backed out changeset fae7d9814403 for mochitest browser-chrome failure on browser_test_performance_metrics.js
Assignee | ||
Comment 26•6 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=78e3194e55e03fa38c971b40b4b4aebd0b6ee9b4
Comment hidden (mozreview-request) |
Comment 28•6 years ago
|
||
Pushed by tziade@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/e5d375c99fa4 Extend PContent to retrieve Performance Counters in the parent process - r=baku
Comment 29•6 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/e5d375c99fa4
Status: NEW → RESOLVED
Closed: 6 years ago
status-firefox61:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla61
Comment 30•6 years ago
|
||
I don't understand the code landed here. https://hg.mozilla.org/mozilla-central/rev/e5d375c99fa4#l10.69 Several TabChilds may share one TabGroup.
Flags: needinfo?(tarek)
Assignee | ||
Comment 31•6 years ago
|
||
We might hit duplicates then, I guess we need to ignore TabGroup that were already iterated over. I have filed bug 1468444 - thanks!
Flags: needinfo?(tarek)
You need to log in
before you can comment on or make changes to this bug.
Description
•