Commit graph

240 commits

Author SHA1 Message Date
kriswright
177b0c2154 Bug 1876306 - Signal to content processes shutting down to raise the QoS priority of their main thread, then ignore all other QoS changes. r=nika
This patch introduces QOS_PRIORITY_SHUTDOWN, which exists exclusively to signal to QoS managing code that we want to raise the priority and accept no other changes. I decided to make this modification directly in `ContentParent` since all QoS changes come through here, and then we can use it while sending a shutdown signal. That way when we actually reach SendShutdown(), we've already warmed up the main thread.

This patch also introduces an assertion in case we somehow don't get a QoS override to catch any potential edge cases where this might be happening.

Differential Revision: https://phabricator.services.mozilla.com/D199497
2024-03-08 17:25:24 +00:00
Artur Iunusov
846d706740 Bug 1770944 - removed unused ProcessPriorityManagerImpl::ResetPriority r=smaug
Depends on D190918

Differential Revision: https://phabricator.services.mozilla.com/D191704
2024-03-07 13:04:24 +00:00
Artur Iunusov
3a0843a675 Bug 1770944 - Remove nsIMozBrowserFrame. r=smaug
Depends on D155254

Differential Revision: https://phabricator.services.mozilla.com/D170397
2024-03-07 13:04:21 +00:00
Narcis Beleuzu
7eae8c1064 Backed out 16 changesets (bug 1770944) as req by asuth.
Backed out changeset 61af32f40777 (bug 1770944)
Backed out changeset 4ff0c45db93b (bug 1770944)
Backed out changeset 8a217eff7bcd (bug 1770944)
Backed out changeset 6435f48c96bf (bug 1770944)
Backed out changeset 0d2432765ca0 (bug 1770944)
Backed out changeset 58e02566db85 (bug 1770944)
Backed out changeset 0a8c4c2460ee (bug 1770944)
Backed out changeset 9416bafd9982 (bug 1770944)
Backed out changeset 79de4f83fe2e (bug 1770944)
Backed out changeset 63ac518aceb0 (bug 1770944)
Backed out changeset 14952f872b77 (bug 1770944)
Backed out changeset f65e0967ad75 (bug 1770944)
Backed out changeset bd53c42038f7 (bug 1770944)
Backed out changeset 36c378ba8212 (bug 1770944)
Backed out changeset 9ba54ab06348 (bug 1770944)
Backed out changeset fb5a54b3cbe9 (bug 1770944)
2024-02-23 21:11:08 +02:00
Artur Iunusov
489616bbc5 Bug 1770944 - removed unused ProcessPriorityManagerImpl::ResetPriority r=smaug
Depends on D190918

Differential Revision: https://phabricator.services.mozilla.com/D191704
2024-02-22 10:13:16 +00:00
Artur Iunusov
b4d482e568 Bug 1770944 - Remove nsIMozBrowserFrame. r=smaug
Depends on D155254

Differential Revision: https://phabricator.services.mozilla.com/D170397
2024-02-22 10:13:13 +00:00
Sandor Molnar
be27c149eb Backed out 16 changesets (bug 1770944) for causing asan failures @ dom/base/InProcessBrowserChildMessageManager.cpp
Backed out changeset b73885731e73 (bug 1770944)
Backed out changeset 23d0dc98eb51 (bug 1770944)
Backed out changeset 15661e24d8e1 (bug 1770944)
Backed out changeset 97aa839dc200 (bug 1770944)
Backed out changeset 0d4318bf3239 (bug 1770944)
Backed out changeset be28bb62e9f3 (bug 1770944)
Backed out changeset 708b2671410e (bug 1770944)
Backed out changeset 0a138f3b56b9 (bug 1770944)
Backed out changeset 3a149ef794c2 (bug 1770944)
Backed out changeset 4b6ae7dd0e69 (bug 1770944)
Backed out changeset e3960ad85182 (bug 1770944)
Backed out changeset 9ea253525227 (bug 1770944)
Backed out changeset 1828b66c2f7c (bug 1770944)
Backed out changeset 55b0886f9025 (bug 1770944)
Backed out changeset a4197071d10a (bug 1770944)
Backed out changeset 9b18524f541e (bug 1770944)
2024-02-20 20:34:55 +02:00
Artur Iunusov
dc7f06952a Bug 1770944 - removed unused ProcessPriorityManagerImpl::ResetPriority r=smaug
Depends on D190918

Differential Revision: https://phabricator.services.mozilla.com/D191704
2024-02-20 16:53:25 +00:00
Artur Iunusov
e6a0102a3b Bug 1770944 - Remove nsIMozBrowserFrame. r=smaug
Depends on D155254

Differential Revision: https://phabricator.services.mozilla.com/D170397
2024-02-20 16:53:22 +00:00
kriswright
51331a8ca5 Bug 1834629 - Set main thread QoS Priority from another thread. r=mccr8
This bug uses the existing process hang messaging infrastructure to raise priorities on main threads. To ensure reduced latency, we also increase the priority of ProcessHangMon threads. We also address an edge-case bug where flipping the QoS prefs during use might lead to a tab getting stuck at the wrong priority.

Due to increasing the priority of the hang monitor thread, we may see some increase in its utilization on MacOS during high CPU load. I'm not sure the extent of how this may impact the browser, but as it makes the thread "faster" it may be more responsive than some other threads during this case.

I tested thread responsiveness by using the stress tool and dispatching various numbers of worker threads, up to 250. During these tests, even when other parts of firefox were less responsive under stress, tab switching appeared to remain snappy and responsive.

I captured some updated power profiles using the change. Profile where pref flipped off during use: https://share.firefox.dev/46BksO3 (Note that we start with the prefs on, then we flip off the prefs half way and repeat the same behavior to observe the fix to the previous bug that left tabs trapped in the background)

Profile with the pref fully enabled: https://share.firefox.dev/46EBIC7

In regards to the edge case, to avoid spurious tab wakeups, we won't reinstate normal thread priority when pref is disabled until the tab is interacted with again.

Differential Revision: https://phabricator.services.mozilla.com/D182787
2023-07-14 16:13:00 +00:00
Narcis Beleuzu
060e6a5a23 Backed out changeset 70e3969301b9 (bug 1834629) for bustages on ProcessHangMonitor.cpp . CLOSED TREE 2023-07-13 21:00:46 +03:00
kriswright
e6c30dd889 Bug 1834629 - Set main thread QoS Priority from another thread. r=mccr8
This bug uses the existing process hang messaging infrastructure to raise priorities on main threads. To ensure reduced latency, we also increase the priority of ProcessHangMon threads. We also address an edge-case bug where flipping the QoS prefs during use might lead to a tab getting stuck at the wrong priority.

Due to increasing the priority of the hang monitor thread, we may see some increase in its utilization on MacOS during high CPU load. I'm not sure the extent of how this may impact the browser, but as it makes the thread "faster" it may be more responsive than some other threads during this case.

I tested thread responsiveness by using the stress tool and dispatching various numbers of worker threads, up to 250. During these tests, even when other parts of firefox were less responsive under stress, tab switching appeared to remain snappy and responsive.

I captured some updated power profiles using the change. Profile where pref flipped off during use: https://share.firefox.dev/46BksO3 (Note that we start with the prefs on, then we flip off the prefs half way and repeat the same behavior to observe the fix to the previous bug that left tabs trapped in the background)

Profile with the pref fully enabled: https://share.firefox.dev/46EBIC7

In regards to the edge case, to avoid spurious tab wakeups, we won't reinstate normal thread priority when pref is disabled until the tab is interacted with again.

Differential Revision: https://phabricator.services.mozilla.com/D182787
2023-07-13 15:44:03 +00:00
Gregory Pappas
82e30282ab Bug 1697605 - Remove MOZ_DISABLE_OOP_TABS and dom.ipc.tabs.disabled r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D181015
2023-06-15 15:58:28 +00:00
Emilio Cobos Álvarez
9b454efc91 Bug 1770458 - Don't pass null to format string in some logging code.
Differential Revision: https://phabricator.services.mozilla.com/D146929
2022-05-20 17:48:13 +00:00
Emilio Cobos Álvarez
b6782fe2d5 Bug 1767346 - Use browsing context activeness rather than renderLayers to determine process priority. r=mccr8,mconley,geckoview-reviewers,agi
For desktop this should basically have no impact (maybe impacts tab
warming, but if we wanted we could set the priority hint from the tab
switcher the same way we set renderLayers), but Fenix always has
renderLayers as true, effectively, so we were never de-prioritizing the
background tab processes.

Differential Revision: https://phabricator.services.mozilla.com/D145351
2022-05-20 09:14:42 +00:00
Marian-Vasile Laza
fadf2bc15a Backed out changeset 7b3a02a659ef (bug 1767346) for causing geckoview failures. CLOSED TREE 2022-05-20 05:23:28 +03:00
Emilio Cobos Álvarez
d6edcc48bb Bug 1767346 - Use browsing context activeness rather than renderLayers to determine process priority. r=mccr8,mconley,geckoview-reviewers,agi
For desktop this should basically have no impact (maybe impacts tab
warming, but if we wanted we could set the priority hint from the tab
switcher the same way we set renderLayers), but Fenix always has
renderLayers as true, effectively, so we were never de-prioritizing the
background tab processes.

Differential Revision: https://phabricator.services.mozilla.com/D145351
2022-05-20 00:48:32 +00:00
Cathy Lu
b5b91ffc69 Bug 1753700 - Add priorityHint to allow apps to increase process priority for background tabs r=geckoview-reviewers,mccr8,agi
Prior behavior for active tabs in an inactive app would have the process priority oom score of 15. Now it's set to a higher priority oom score of 11. This will increase priority for recently used tabs on apps and prevent Android from unloading them.

Differential Revision: https://phabricator.services.mozilla.com/D142386
2022-04-04 17:41:37 +00:00
Cosmin Sabou
ff0de58ac3 Backed out changeset b7dc5de07187 (bug 1753700) for causing android mochitest failures on test_ext_tabs_getCurrent.html. CLOSED TREE 2022-04-02 01:28:06 +03:00
Cathy Lu
2a809cdea0 Bug 1753700 - Add priorityHint to allow apps to increase process priority for background tabs r=geckoview-reviewers,mccr8,agi
Prior behavior for active tabs in an inactive app would have the process priority oom score of 15. Now it's set to a higher priority oom score of 11. This will increase priority for recently used tabs on apps and prevent Android from unloading them.

Differential Revision: https://phabricator.services.mozilla.com/D142386
2022-04-01 17:44:33 +00:00
Iulian Moraru
d7933a01b3 Backed out changeset 4a083131d350 (bug 1753700) for causing linting failures on browser_ProcessPriorityManager.js. CLOSED TREE 2022-04-01 19:37:35 +03:00
Cathy Lu
8b26a85901 Bug 1753700 - Add priorityHint to allow apps to increase process priority for background tabs r=geckoview-reviewers,mccr8,agi
Prior behavior for active tabs in an inactive app would have the process priority oom score of 15. Now it's set to a higher priority oom score of 11. This will increase priority for recently used tabs on apps and prevent Android from unloading them.

Differential Revision: https://phabricator.services.mozilla.com/D142386
2022-04-01 16:10:47 +00:00
Cathy Lu
104eb166e9 Bug 1753700 - Rename ActivityChanged to BrowserPriorityChanged. r=mccr8
Differential Revision: https://phabricator.services.mozilla.com/D141531
2022-04-01 14:42:41 +00:00
Florian Quèze
f84ed84ce8 Bug 1747138 - Breakdown CPU and GPU time by process type, r=chutten,gsvelto
Differential Revision: https://phabricator.services.mozilla.com/D134441
2022-02-03 20:37:21 +00:00
smolnar
4d305a2b14 Backed out changeset cd96e020a609 (bug 1747138) for causing bc failures in browser_telemetry_video_hardware_decoding_support. CLOSED TREE 2022-02-03 19:51:02 +02:00
Florian Quèze
b8e6ccc49a Bug 1747138 - Breakdown CPU and GPU time by process type, r=chutten,gsvelto
Differential Revision: https://phabricator.services.mozilla.com/D134441
2022-02-03 12:20:15 +00:00
Nazım Can Altınova
a38b25b295 Bug 1728544 - Make the MarkerSchema::Format enum class values CamelCased r=gerald
Differential Revision: https://phabricator.services.mozilla.com/D124241
2021-09-03 14:30:10 +00:00
Nazım Can Altınova
ddae0f7cd6 Bug 1728544 - Make the MarkerSchema::Location enum class values CamelCased r=gerald
Differential Revision: https://phabricator.services.mozilla.com/D124240
2021-09-03 14:30:09 +00:00
Florian Quèze
cd399a71a2 Bug 1717991 - Remove ifdefs around code that adds profiler markers with custom marker schemas, r=gerald.
Differential Revision: https://phabricator.services.mozilla.com/D118680
2021-06-25 13:28:01 +00:00
Gerald Squelart
fc95c6ad29 Bug 1667818 - Record priority change markers - r=canaltinova
In the parent process, all sub-process priority changes are recorded, with the stack.
In child processes, the new priority is recorded when notified.

Also record priorities during profiler state changes. This is to ensure that we always have at least one record of the priority at the end of the profile, when old priority changes may have already been discarded.

Differential Revision: https://phabricator.services.mozilla.com/D118129
2021-06-24 07:25:56 +00:00
Andrew McCreight
1ff63b852e Bug 1715311 - Null check GetBrowserParent() in ProcessPriorityManagerImpl::ActivityChanged. r=kmag
Differential Revision: https://phabricator.services.mozilla.com/D117455
2021-06-10 23:06:57 +00:00
Andrew McCreight
b800c441d9 Bug 1712357 - Don't adjust the priority of ContentParents that are going away. r=kmag
Differential Revision: https://phabricator.services.mozilla.com/D116496
2021-06-01 22:49:50 +00:00
Andrew McCreight
fa406e6672 Bug 1709715 - Take advantage of CTAD for GetParticularProcessPriorityManager(). r=kmag
Differential Revision: https://phabricator.services.mozilla.com/D114406
2021-05-21 21:13:05 +00:00
Andrew McCreight
72e921c0d9 Bug 1709931 - Properly shut down ParticularProcessPriorityManager when destroying it. r=gsvelto
Differential Revision: https://phabricator.services.mozilla.com/D114777
2021-05-12 20:34:29 +00:00
Andrew McCreight
9c9c36a9fa Bug 1710473 - Remove hal::SetProcessPrioritySupported(). r=gsvelto,geckoview-reviewers,aklotz
As far as I can see, all this does is protect the user from
running some useless code if they manually enable the priority
manager using a pref on an OS that doesn't support it. The
upside of allowing this is that it makes it possible to debug
the priority manager on OSX and Linux with just a pref flip.

Differential Revision: https://phabricator.services.mozilla.com/D114767
2021-05-10 19:59:24 +00:00
Andrew McCreight
0688567b46 Bug 1618547 - Support Fission in the process priority manager. r=kmag,gsvelto
With Fission, there can be multiple BrowserParents in a single tab, so
this patch moves the tracking of active tabs onto the top BrowsingContext
in a tab. If the priority of a top BC is changed, then the activity
of all of the BPs of the BCs in the tree are all adjusted. The flag
that tracks this state gets carried forward to the new BC in the case
of a cross-group navigation by the changes in ReplacedBy().

The other change here covers the case where we do a process-switching
navigation on an iframe. If we create a new BrowserParent with an active
top BC, then the BP gets marked as active in the priority manager. Doing
this tracking on the BP instead of the BC (both here in and in the part
that landed previously in BrowserParent::Deactivated()) means that we
don't need to track down every place that a BC switches processes.

I left the tracking of activity in ParticularProcessPriorityManager
centered around BrowserParents, instead of changing it to BCs, to
minimize the changes required. There are some tricky interactions there
with wakelocks that I didn't want to have to figure out.

browser_ProcessPriorityManager.js was set up to track a mapping of
browsers to priorities, but for the purposes of testing Fission support
I changed it to track a mapping of child IDs to priorities.

In the test, I also removed an assignment (this.window = null) that
didn't seem to be doing anything.

Differential Revision: https://phabricator.services.mozilla.com/D112213
2021-05-07 17:51:34 +00:00
Noemi Erli
b7da3f34ee Backed out changeset f45996fe15b2 (bug 1618547) for causing failures in browser_ProcessPriorityManager.js CLOSED TREE 2021-05-06 00:53:54 +03:00
Andrew McCreight
063f9001b0 Bug 1618547 - Support Fission in the process priority manager. r=kmag,gsvelto
With Fission, there can be multiple BrowserParents in a single tab, so
this patch moves the tracking of active tabs onto the top BrowsingContext
in a tab. If the priority of a top BC is changed, then the activity
of all of the BPs of the BCs in the tree are all adjusted. The flag
that tracks this state gets carried forward to the new BC in the case
of a cross-group navigation by the changes in ReplacedBy().

The other change here covers the case where we do a process-switching
navigation on an iframe. If we create a new BrowserParent with an active
top BC, then the BP gets marked as active in the priority manager. Doing
this tracking on the BP instead of the BC (both here in and in the part
that landed previously in BrowserParent::Deactivated()) means that we
don't need to track down every place that a BC switches processes.

I left the tracking of activity in ParticularProcessPriorityManager
centered around BrowserParents, instead of changing it to BCs, to
minimize the changes required. There are some tricky interactions there
with wakelocks that I didn't want to have to figure out.

browser_ProcessPriorityManager.js was set up to track a mapping of
browsers to priorities, but for the purposes of testing Fission support
I changed it to track a mapping of child IDs to priorities.

In the test, I also removed an assignment (this.window = null) that
didn't seem to be doing anything.

Differential Revision: https://phabricator.services.mozilla.com/D112213
2021-05-05 20:29:14 +00:00
Andrew McCreight
1f773eeaa5 Bug 1704545, part 3 - Tell the priority manager when a browser parent is deactivated. r=gsvelto,kmag
The priority manager tracks which browser parents are active in each process,
so it needs to be told when a browser parent is no longer active. This
is currently implemented by observing ipc:browser-destroyed, which happens
in BrowserHost::DestroyComplete().

However, with Fission, not all BrowserParents are held by BrowserHosts. I
don't think this is an issue right now, but if the priority manager is going
to properly prioritize processes due to the presence of active non-top-level
frames, then it needs to also deprioritize them when they go away.

This patch deals with this situation by directly telling the priority
manager that the browser parent is becoming inactive via the existing
ActivityChanged method, in the BrowserParent::Deactivated() method,
which is called when a browser parent is being destroyed or entering
the BF cache. I think it makes sense in both cases that we no longer
want to prioritize the process that the page is in.

This does mean that we are telling the priority manager about more
ContentParents which is potentially more expensive, but the old code
also ended up doing a hashtable remove in every single
ParticularProcessPriorityManager, whereas the new code only does it
for one, so hopefully it is a net win overall.

(The reason for this is that in ParticularProcessPriorityManager's
OnBrowserParentDestroyed() method the browserHost->GetContentParent()
check will always return null because the browser host nulls out
mRoot immediately before it does ipc:browser-destroyed, so the hash
table remove is never skipped.)

This patch also removes the last thing that ParticularProcessPriorityManager
was observing, so it no longer needs to be an nsIObserver.

Differential Revision: https://phabricator.services.mozilla.com/D111654
2021-04-12 23:42:53 +00:00
Andrew McCreight
13e85e827c Bug 1704545, part 2 - Rename TabActivityChanged to ActivityChanged. r=gsvelto
As of the next patch, it won't be used just for indicating the
activity of an entire tab, so let's rename it.

Also alphabetize the order of some forward declarations.

Differential Revision: https://phabricator.services.mozilla.com/D111701
2021-04-12 23:42:53 +00:00
Andrew McCreight
dafba67ef6 Bug 1704545, part 1 - Make the priority manager's OnRemoteBrowserFrameShown into a direct call. r=gsvelto
ParticularProcessPriorityManager observes remote-browser-shown and recomputes
the priority for the given browser. This patch eliminates the observer call
and instead makes the frame loader do a direct call.

I think doing it this way is a little clearer, and also the next patch will
eliminate the other reason ParticularProcessPriorityManager is an observer,
which will let us not not register something as an observer for every content
process, which I think is also good.

There should be no change in behavior.

Differential Revision: https://phabricator.services.mozilla.com/D111653
2021-04-12 23:42:52 +00:00
Andrew McCreight
d0b8da9d24 Bug 1702795, part 3 - Inline one overload of FireTestOnlyObserverNotification. r=gsvelto
Also remove the default arguments. This function is only called in a single
place, so drop some of the unnecessary generality.

Differential Revision: https://phabricator.services.mozilla.com/D110709
2021-04-05 20:17:58 +00:00
Andrew McCreight
68c232e988 Bug 1702795, part 2 - Be lazier about creating a ParticularProcessPriorityManager. r=gsvelto
The only reason to immediate create a ParticularProcessPriorityManager
when a ContentParent is created is to ensure that the test only
observer notification for process-created is accurate, but no test
actually listens for it, so we can delete the test notification
and then stop observing ipc:content-created.

Differential Revision: https://phabricator.services.mozilla.com/D110708
2021-04-05 20:17:58 +00:00
Andrew McCreight
963e338e74 Bug 1702795, part 1 - This check is redundant with the previous block of code. r=gsvelto
Looks like a bit of refactoring cruft from bug 1368029.

Differential Revision: https://phabricator.services.mozilla.com/D110707
2021-04-05 20:17:58 +00:00
Simon Giesecke
45420d4e39 Bug 708901 - Migrate to nsTHashSet in dom/ipc. r=nika
Depends on D108597

Differential Revision: https://phabricator.services.mozilla.com/D108598
2021-03-23 10:36:34 +00:00
Simon Giesecke
bc9766c354 Bug 1634281 - Use nsTHashMap for nsBaseHashtable/nsDataHashtable uses with RefPtr data type. r=xpcom-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D105963
2021-03-09 11:39:36 +00:00
Simon Giesecke
4df825df71 Bug 1688833 - Migrate LookupForAdd to WithEntryHandle in dom/ipc. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D104201
2021-02-09 18:19:38 +00:00
Simon Giesecke
de7bab0f06 Bug 1650145 - Replace all value uses of Empty[C]String by 0-length _ns literals. r=froydnj,geckoview-reviewers,agi
Differential Revision: https://phabricator.services.mozilla.com/D82325
2020-09-23 15:17:15 +00:00
Nathan Froyd
cfb8fb313f Bug 1662251 - stop assigning from NS_Convert* values, mostly; r=sg
This patch was generated by running:

```
perl -p -i \
     -e 's/^(\s+)([a-zA-Z0-9.]+) = NS_ConvertUTF8toUTF16\((.*)\);/\1CopyUTF8toUTF16(\3, \2);/;' \
     -e 's/^(\s+)([a-zA-Z0-9.]+) = NS_ConvertUTF16toUTF8\((.*)\);/\1CopyUTF16toUTF8(\3, \2);/;' \
     $FILE
```

against every .cpp and .h in mozilla-central, and then fixing up the
inevitable errors that happen as a result of matching C++ expressions with
regexes.  The errors fell into three categories:

1. Calling the convert functions with `std::string::c_str()`; these were
   changed to simply pass the string instead, relying on implicit conversion
   to `mozilla::Span`.
2. Calling the convert functions with raw pointers, which is not permitted
   with the copy functions; these were changed to invoke `MakeStringSpan` first.
3. Other miscellaneous errors resulting from over-eager regexes and/or the
   replacement not being type-aware.  These changes were reverted.

Differential Revision: https://phabricator.services.mozilla.com/D88903
2020-09-02 09:54:37 +00:00
Nika Layzell
22a65a237e Bug 1650163 - Part 1: Switch native remoteType values to nsCString, r=farre,geckoview-reviewers,agi
Differential Revision: https://phabricator.services.mozilla.com/D82104
2020-07-08 20:15:59 +00:00