Skip to content

Commit

Permalink
Bug 1863912 - Only enable PHC when a system has at least 8GB RAM r=de…
Browse files Browse the repository at this point in the history
…coder

Differential Revision: https://phabricator.services.mozilla.com/D193178
  • Loading branch information
PaulBone committed Nov 9, 2023
1 parent 1fbc2b2 commit 4595ea0
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions xpcom/base/PHCManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "mozilla/Preferences.h"
#include "mozilla/StaticPrefs_memory.h"
#include "mozilla/Telemetry.h"
#include "prsystem.h"

namespace mozilla {

Expand All @@ -28,9 +29,16 @@ static void PrefChangeCallback(const char* aPrefName, void* aNull) {
}

void InitPHCState() {
SetPHCState(GetPHCStateFromPref());

Preferences::RegisterCallback(PrefChangeCallback, kPHCPref);
size_t memSize = PR_GetPhysicalMemorySize();
// Only enable PHC if there are at least 8GB of ram. Note that we use
// 1000 bytes per kilobyte rather than 1024. Some 8GB machines will have
// slightly lower actual RAM available after some hardware devices
// reserve some.
if (memSize >= size_t(8'000'000'000llu)) {
SetPHCState(GetPHCStateFromPref());

Preferences::RegisterCallback(PrefChangeCallback, kPHCPref);
}
}

void ReportPHCTelemetry() {
Expand Down

0 comments on commit 4595ea0

Please sign in to comment.