Bug 1800412 - Add a preference to control whether the EcoQoS is used for background content processes, r=gsvelto.

Differential Revision: https://phabricator.services.mozilla.com/D161975
This commit is contained in:
Florian Queze 2022-11-14 12:10:55 +00:00
parent 47ba0361d4
commit 96cc120704
3 changed files with 23 additions and 3 deletions

View file

@ -2076,6 +2076,10 @@ pref("extensions.experiments.enabled", false);
pref("dom.ipc.processPriorityManager.enabled", true);
#endif
#if defined(XP_WIN)
pref("dom.ipc.processPriorityManager.backgroundUsesEcoQoS", true);
#endif
// Don't limit how many nodes we care about on desktop:
pref("reader.parse-node-limit", 0);

View file

@ -11,6 +11,7 @@
#include "Hal.h"
#include "HalLog.h"
#include "nsWindowsHelpers.h" // for nsAutoHandle and nsModuleHandle
#include "mozilla/StaticPrefs_dom.h"
#include <windows.h>
@ -42,6 +43,11 @@ void SetProcessPriority(int aPid, ProcessPriority aPriority) {
static bool alreadyInitialized = false;
static decltype(::SetProcessInformation)* setProcessInformation = nullptr;
if (!alreadyInitialized) {
if (aPriority == PROCESS_PRIORITY_PARENT_PROCESS ||
!StaticPrefs::dom_ipc_processPriorityManager_backgroundUsesEcoQoS()) {
return;
}
alreadyInitialized = true;
// SetProcessInformation only exists on Windows 8 and later.
nsModuleHandle module(LoadLibrary(L"Kernel32.dll"));
@ -59,9 +65,12 @@ void SetProcessPriority(int aPid, ProcessPriority aPriority) {
RtlZeroMemory(&PowerThrottling, sizeof(PowerThrottling));
PowerThrottling.Version = PROCESS_POWER_THROTTLING_CURRENT_VERSION;
PowerThrottling.ControlMask = PROCESS_POWER_THROTTLING_EXECUTION_SPEED;
PowerThrottling.StateMask = aPriority == PROCESS_PRIORITY_BACKGROUND
? PROCESS_POWER_THROTTLING_EXECUTION_SPEED
: 0;
PowerThrottling.StateMask =
(aPriority == PROCESS_PRIORITY_BACKGROUND) &&
StaticPrefs::
dom_ipc_processPriorityManager_backgroundUsesEcoQoS()
? PROCESS_POWER_THROTTLING_EXECUTION_SPEED
: 0;
if (setProcessInformation(processHandle, ProcessPowerThrottling,
&PowerThrottling, sizeof(PowerThrottling))) {
HAL_LOG("SetProcessInformation(%d, %s)\n", aPid,

View file

@ -2863,6 +2863,13 @@
#endif
mirror: always
#ifdef XP_WIN
- name: dom.ipc.processPriorityManager.backgroundUsesEcoQoS
type: bool
value: false
mirror: always
#endif
# Is support for HTMLElement.autocapitalize enabled?
- name: dom.forms.autocapitalize
type: bool