Bug 1376038 - Part 1: Use a cached ghost window value for the distinguished amount. r=mccr8
We already periodically calculate the ghost window amount after cycle collection, this just uses a cached value of that for the distinguished amount. This avoids the overhead of a recalculating the value when reporting telemetry.
This commit is contained in:
@@ -34,7 +34,8 @@ const int32_t kTimeBetweenChecks = 45; /* seconds */
|
||||
nsWindowMemoryReporter::nsWindowMemoryReporter()
|
||||
: mLastCheckForGhostWindows(TimeStamp::NowLoRes()),
|
||||
mCycleCollectorIsRunning(false),
|
||||
mCheckTimerWaitingForCCEnd(false)
|
||||
mCheckTimerWaitingForCCEnd(false),
|
||||
mGhostWindowCount(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -757,6 +758,7 @@ nsWindowMemoryReporter::CheckForGhostWindows(
|
||||
// if it's not null.
|
||||
uint32_t ghostTimeout = GetGhostTimeout();
|
||||
TimeStamp now = mLastCheckForGhostWindows;
|
||||
mGhostWindowCount = 0;
|
||||
for (auto iter = mDetachedWindows.Iter(); !iter.Done(); iter.Next()) {
|
||||
nsWeakPtr weakKey = do_QueryInterface(iter.Key());
|
||||
nsCOMPtr<mozIDOMWindow> iwindow = do_QueryReferent(weakKey);
|
||||
@@ -809,6 +811,7 @@ nsWindowMemoryReporter::CheckForGhostWindows(
|
||||
// that is not null.
|
||||
if (aOutGhostIDs && window) {
|
||||
aOutGhostIDs->PutEntry(window->WindowID());
|
||||
mGhostWindowCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -821,9 +824,7 @@ NS_IMPL_ISUPPORTS(nsWindowMemoryReporter::GhostWindowsReporter,
|
||||
/* static */ int64_t
|
||||
nsWindowMemoryReporter::GhostWindowsReporter::DistinguishedAmount()
|
||||
{
|
||||
nsTHashtable<nsUint64HashKey> ghostWindows;
|
||||
sWindowReporter->CheckForGhostWindows(&ghostWindows);
|
||||
return ghostWindows.Count();
|
||||
return sWindowReporter->mGhostWindowCount;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user