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()
|
nsWindowMemoryReporter::nsWindowMemoryReporter()
|
||||||
: mLastCheckForGhostWindows(TimeStamp::NowLoRes()),
|
: mLastCheckForGhostWindows(TimeStamp::NowLoRes()),
|
||||||
mCycleCollectorIsRunning(false),
|
mCycleCollectorIsRunning(false),
|
||||||
mCheckTimerWaitingForCCEnd(false)
|
mCheckTimerWaitingForCCEnd(false),
|
||||||
|
mGhostWindowCount(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -757,6 +758,7 @@ nsWindowMemoryReporter::CheckForGhostWindows(
|
|||||||
// if it's not null.
|
// if it's not null.
|
||||||
uint32_t ghostTimeout = GetGhostTimeout();
|
uint32_t ghostTimeout = GetGhostTimeout();
|
||||||
TimeStamp now = mLastCheckForGhostWindows;
|
TimeStamp now = mLastCheckForGhostWindows;
|
||||||
|
mGhostWindowCount = 0;
|
||||||
for (auto iter = mDetachedWindows.Iter(); !iter.Done(); iter.Next()) {
|
for (auto iter = mDetachedWindows.Iter(); !iter.Done(); iter.Next()) {
|
||||||
nsWeakPtr weakKey = do_QueryInterface(iter.Key());
|
nsWeakPtr weakKey = do_QueryInterface(iter.Key());
|
||||||
nsCOMPtr<mozIDOMWindow> iwindow = do_QueryReferent(weakKey);
|
nsCOMPtr<mozIDOMWindow> iwindow = do_QueryReferent(weakKey);
|
||||||
@@ -809,6 +811,7 @@ nsWindowMemoryReporter::CheckForGhostWindows(
|
|||||||
// that is not null.
|
// that is not null.
|
||||||
if (aOutGhostIDs && window) {
|
if (aOutGhostIDs && window) {
|
||||||
aOutGhostIDs->PutEntry(window->WindowID());
|
aOutGhostIDs->PutEntry(window->WindowID());
|
||||||
|
mGhostWindowCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -821,9 +824,7 @@ NS_IMPL_ISUPPORTS(nsWindowMemoryReporter::GhostWindowsReporter,
|
|||||||
/* static */ int64_t
|
/* static */ int64_t
|
||||||
nsWindowMemoryReporter::GhostWindowsReporter::DistinguishedAmount()
|
nsWindowMemoryReporter::GhostWindowsReporter::DistinguishedAmount()
|
||||||
{
|
{
|
||||||
nsTHashtable<nsUint64HashKey> ghostWindows;
|
return sWindowReporter->mGhostWindowCount;
|
||||||
sWindowReporter->CheckForGhostWindows(&ghostWindows);
|
|
||||||
return ghostWindows.Count();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -258,6 +258,8 @@ private:
|
|||||||
bool mCycleCollectorIsRunning;
|
bool mCycleCollectorIsRunning;
|
||||||
|
|
||||||
bool mCheckTimerWaitingForCCEnd;
|
bool mCheckTimerWaitingForCCEnd;
|
||||||
|
|
||||||
|
int64_t mGhostWindowCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // nsWindowMemoryReporter_h__
|
#endif // nsWindowMemoryReporter_h__
|
||||||
|
|||||||
@@ -374,7 +374,8 @@ interface nsIMemoryReporterManager : nsISupports
|
|||||||
* of low-{virtual,physical}-memory events that have occurred since the
|
* of low-{virtual,physical}-memory events that have occurred since the
|
||||||
* process started.
|
* process started.
|
||||||
*
|
*
|
||||||
* |ghostWindows| (UNITS_COUNT) The number of ghost windows.
|
* |ghostWindows| (UNITS_COUNT) A cached value of the number of ghost
|
||||||
|
* windows. This should have been updated within the past 60s.
|
||||||
*
|
*
|
||||||
* |pageFaultsHard| (UNITS_COUNT_CUMULATIVE) The number of hard (a.k.a.
|
* |pageFaultsHard| (UNITS_COUNT_CUMULATIVE) The number of hard (a.k.a.
|
||||||
* major) page faults that have occurred since the process started.
|
* major) page faults that have occurred since the process started.
|
||||||
|
|||||||
Reference in New Issue
Block a user