about:processes uses too much CPU
Categories
(Core :: DOM: Content Processes, defect, P2)
Tracking
()
Tracking | Status | |
---|---|---|
firefox80 | --- | fixed |
People
(Reporter: Yoric, Assigned: Yoric)
References
Details
Attachments
(3 files, 3 obsolete files)
Apparently, about:processes
takes 25-30% on some machines. Let's fix that.
Ryan, could you tell us more? Which OS are you using?
Assignee | ||
Updated•4 years ago
|
Comment 1•4 years ago
|
||
Comment 2•4 years ago
|
||
Here's a profile of it: https://share.firefox.dev/2W5mXWw
Assignee | ||
Comment 3•4 years ago
•
|
||
Thanks.
So, it looks like calls to Thread32Next
are expensive and we're calling it quite often. Looking at it a bit more in detail, we're doing the following:
- For each process
- Take a snapshot of the entire OS
- Walk through all the threads of this snapshot
- Discard the threads that do not match the current process
Looks like we could be quite a bit more efficient by taking a single snapshot and iterating through it once. This would mean reworking the calling code in ChromeUtils
to avoid assuming that we handle each process separately.
I might also move this code to ProcessToolsService
, to be determined.
Assignee | ||
Comment 4•4 years ago
|
||
So, I'd say:
- Rework
ProcInfo::GetProcInfo
to take as argument an array of partially-filledProcInfo
instead of a singleProcInfo
. - Rework the calling code from
ChromeUtils::RequestProcInfo
accordingly.
Assignee | ||
Comment 5•4 years ago
|
||
The current implementation of GetProcInfo
is inefficient under Windows as it takes
one snapshot of the entire OS per process, then needs to walk each of these global
snapshots looking for information on the single process.
This patch changes the API and client caller RequestProcInfo
to be able to share
a single snapshot.
Updated•4 years ago
|
Assignee | ||
Comment 6•4 years ago
|
||
GetProcInfo
relies upon Thread32First
/Thread32Next
, both of which are quite CPU-expensive.
This patch refactors GetProcInfo
to decrease the number of calls to Thread32Next
from
~O(T * P) to ~O(T), where T is the number of threads on the OS and P is the number of Firefox
processes launched.
Depends on D83335
Assignee | ||
Comment 7•4 years ago
|
||
Assignee | ||
Comment 8•4 years ago
|
||
Depends on D83336
Updated•4 years ago
|
Assignee | ||
Comment 9•4 years ago
|
||
Depends on D83371
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Assignee | ||
Comment 10•4 years ago
|
||
Updated•4 years ago
|
Assignee | ||
Comment 11•4 years ago
|
||
Florian, Ryan, once this patch has landed, could you confirm that it improves CPU usage on your Windows machines?
Comment 12•4 years ago
|
||
Pushed by dteller@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/22bb2a5032b7 Refactoring ChromeUtils::RequestProcInfo to place a single request to GetProcInfo;r=tarek https://hg.mozilla.org/integration/autoland/rev/5f02a357671c A little lifetime documentation;r=nika
Comment 13•4 years ago
|
||
Backed out for bustages on ChromeUtils.cpp
Backout link: https://hg.mozilla.org/integration/autoland/rev/bc330da2b11b420c6907b136db6b7342bc50ea3e
Log link: https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=310189138&repo=autoland&lineNumber=44969
Updated•4 years ago
|
Assignee | ||
Updated•4 years ago
|
Comment 14•4 years ago
|
||
I hope we're taking the toolhelp32 snapshot off main thread as well; that call is super expensive.
Comment 15•4 years ago
|
||
Pushed by dteller@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/0a6cb920a247 Refactoring ChromeUtils::RequestProcInfo to place a single request to GetProcInfo;r=tarek,geckoview-reviewers,agi https://hg.mozilla.org/integration/autoland/rev/69dbf38f4071 A little lifetime documentation;r=nika
Comment 16•4 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/0a6cb920a247
https://hg.mozilla.org/mozilla-central/rev/69dbf38f4071
Comment 17•4 years ago
|
||
Backout by csabou@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/fd92c0395206 Backed out 2 changesets for causing Bug 1653749.
Comment 18•4 years ago
|
||
Failure logs: https://treeherder.mozilla.org/logviewer.html#?job_id=310279082&repo=autoland
https://treeherder.mozilla.org/logviewer.html#?job_id=310279090&repo=autoland
https://treeherder.mozilla.org/logviewer.html#?job_id=310279093&repo=autoland
Backout link: https://hg.mozilla.org/integration/autoland/rev/fd92c039520627dcc8cd26cbfbbc052227195cb7
Comment 20•4 years ago
|
||
Backout merged to central: https://hg.mozilla.org/mozilla-central/rev/fd92c0395206
Assignee | ||
Comment 21•4 years ago
|
||
So, tests confirm that if I remove the 3-liner that was supposed to fix bug 1642257, we don't crash anymore.
Let's land the part that works and deal with the other bug in the other bug.
Comment 22•4 years ago
|
||
Pushed by dteller@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/d52e4d4a3788 Refactoring ChromeUtils::RequestProcInfo to place a single request to GetProcInfo;r=tarek,geckoview-reviewers,agi https://hg.mozilla.org/integration/autoland/rev/4603073c15cb A little lifetime documentation;r=nika
Comment 23•4 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/d52e4d4a3788
https://hg.mozilla.org/mozilla-central/rev/4603073c15cb
Assignee | ||
Comment 24•4 years ago
|
||
So we had a tid
of 0 under Windows once.
Odd.
Comment 25•4 years ago
|
||
(In reply to David Teller [:Yoric] (please use "needinfo") from comment #11)
Florian, Ryan, once this patch has landed, could you confirm that it improves CPU usage on your Windows machines?
CPU usage now seems to be 2-4% of one core. Example profile: https://share.firefox.dev/2ZScj7G
Assignee | ||
Comment 27•4 years ago
|
||
We'll call this a victory, then!
Description
•