Backed out changeset 25ec03d2ae24 (bug 1606209) for causing bustages in nsHyphenationManager.cpp

CLOSED TREE
This commit is contained in:
Mihai Alexandru Michis 2020-01-07 01:03:33 +02:00
Родитель c278823866
Коммит c4518fcd8c
3 изменённых файлов: 50 добавлений и 0 удалений

Просмотреть файл

@ -18,6 +18,7 @@
#include "mozilla/Preferences.h"
#include "nsZipArchive.h"
#include "mozilla/Services.h"
#include "mozilla/Telemetry.h"
#include "nsIObserverService.h"
#include "nsCRT.h"
#include "nsAppDirectoryServiceDefs.h"
@ -29,6 +30,13 @@ using namespace mozilla;
static const char kIntlHyphenationAliasPrefix[] = "intl.hyphenation-alias.";
static const char kMemoryPressureNotification[] = "memory-pressure";
// To report memory usage via telemetry, we observe a notification when the
// process is about to be shut down; unfortunately, parent and child processes
// receive different notifications, so we have to account for that in order to
// report usage from both process types.
static const char kParentShuttingDownNotification[] = "profile-before-change";
static const char kChildShuttingDownNotification[] = "content-child-shutdown";
class HyphenReporter final : public nsIMemoryReporter {
private:
~HyphenReporter() = default;
@ -69,7 +77,15 @@ NS_IMETHODIMP
nsHyphenationManager::Observe(nsISupports* aSubject, const char* aTopic,
const char16_t* aData) {
if (!nsCRT::strcmp(aTopic, kMemoryPressureNotification)) {
// We're going to discard hyphenators; record a telemetry entry for the
// memory usage we reached before doing so.
Telemetry::Accumulate(Telemetry::HYPHENATION_MEMORY,
HyphenReporter::MemoryAllocatedInKB());
nsHyphenationManager::sInstance->mHyphenators.Clear();
} else if (!nsCRT::strcmp(aTopic, kParentShuttingDownNotification) ||
!nsCRT::strcmp(aTopic, kChildShuttingDownNotification)) {
Telemetry::Accumulate(Telemetry::HYPHENATION_MEMORY,
HyphenReporter::MemoryAllocatedInKB());
}
return NS_OK;
}
@ -81,6 +97,10 @@ nsHyphenationManager* nsHyphenationManager::Instance() {
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (obs) {
obs->AddObserver(sInstance, kMemoryPressureNotification, false);
obs->AddObserver(sInstance,
XRE_IsParentProcess() ? kParentShuttingDownNotification
: kChildShuttingDownNotification,
false);
}
RegisterStrongMemoryReporter(new HyphenReporter());
@ -93,6 +113,9 @@ void nsHyphenationManager::Shutdown() {
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (obs) {
obs->RemoveObserver(sInstance, kMemoryPressureNotification);
obs->RemoveObserver(sInstance, XRE_IsParentProcess()
? kParentShuttingDownNotification
: kChildShuttingDownNotification);
}
delete sInstance;
sInstance = nullptr;

Просмотреть файл

@ -6,6 +6,7 @@
#include "nsHyphenator.h"
#include "mozilla/dom/ContentChild.h"
#include "mozilla/Telemetry.h"
#include "nsContentUtils.h"
#include "nsIChannel.h"
#include "nsIFile.h"
@ -139,6 +140,8 @@ nsHyphenator::nsHyphenator(nsIURI* aURI, bool aHyphenateCapitalized)
: mDict(static_cast<const void*>(nullptr)),
mDictSize(0),
mHyphenateCapitalized(aHyphenateCapitalized) {
Telemetry::AutoTimer<Telemetry::HYPHENATION_LOAD_TIME> telemetry;
nsCOMPtr<nsIJARURI> jar = do_QueryInterface(aURI);
if (jar) {
// This gives us a raw pointer into the omnijar's data (if uncompressed);

Просмотреть файл

@ -15099,6 +15099,30 @@
"n_buckets": 12,
"description": "Percentages of times for phases in an expensive refresh tick relative to the time spent in the entire tick (REFRESH_DRIVER_TICK)."
},
"HYPHENATION_MEMORY": {
"record_in_processes": ["main", "content"],
"products": ["firefox", "fennec", "geckoview"],
"alert_emails": ["jkew@mozilla.com"],
"bug_numbers": [1568514],
"expires_in_version": "74",
"kind": "exponential",
"high": 8000,
"n_buckets": 100,
"releaseChannelCollection": "opt-out",
"description": "Total per-process memory used by loaded auto-hyphenation tables (KB)."
},
"HYPHENATION_LOAD_TIME": {
"record_in_processes": ["main", "content"],
"products": ["firefox", "fennec", "geckoview"],
"alert_emails": ["jkew@mozilla.com"],
"bug_numbers": [1568514],
"expires_in_version": "74",
"kind": "exponential",
"high": 1000,
"n_buckets": 100,
"releaseChannelCollection": "opt-out",
"description": "How many milliseconds it took to load a hyphenation resource."
},
"PRESSHELL_REQS_PER_STYLE_FLUSH": {
"record_in_processes": ["main", "content"],
"products": ["firefox", "fennec", "geckoview"],