зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1194555 - Part 2: Remove |explicit| attribute from nsIMemoryReporterManager. r=njn
The calculation of |explicit| relies on the synchronous |getReportsForThisProcess|, once we have asynchronous reporters this will no longer work. As it is currently referenced in the about::memory tests we can just remove it.
This commit is contained in:
Родитель
61d0f893cd
Коммит
acd4358a2a
|
@ -119,21 +119,6 @@
|
||||||
mgr.registerStrongReporterEvenIfBlocked(fakeReporters[i]);
|
mgr.registerStrongReporterEvenIfBlocked(fakeReporters[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// mgr.explicit sums "heap-allocated" and all the appropriate NONHEAP ones:
|
|
||||||
// - "explicit/c", "explicit/cc" x 2, "explicit/d", "explicit/e"
|
|
||||||
// - but *not* "explicit/c/d" x 2
|
|
||||||
// Check explicit now before we add the fake reporters for the fake 2nd
|
|
||||||
// and subsequent processes.
|
|
||||||
//
|
|
||||||
// Nb: mgr.explicit will throw NS_ERROR_NOT_AVAILABLE if this is a
|
|
||||||
// --disable-jemalloc build. Allow for that exception, but *only* that
|
|
||||||
// exception.
|
|
||||||
try {
|
|
||||||
is(mgr.explicit, 500*MB + (100 + 13 + 10)*MB + 599*KB, "mgr.explicit");
|
|
||||||
} catch (ex) {
|
|
||||||
is(ex.result, Cr.NS_ERROR_NOT_AVAILABLE, "mgr.explicit exception");
|
|
||||||
}
|
|
||||||
|
|
||||||
// The main process always comes first when we display about:memory. The
|
// The main process always comes first when we display about:memory. The
|
||||||
// remaining processes are sorted by their |resident| values (starting with
|
// remaining processes are sorted by their |resident| values (starting with
|
||||||
// the largest). Processes without a |resident| memory reporter are saved
|
// the largest). Processes without a |resident| memory reporter are saved
|
||||||
|
|
|
@ -141,21 +141,6 @@
|
||||||
let mgr = Cc["@mozilla.org/memory-reporter-manager;1"].
|
let mgr = Cc["@mozilla.org/memory-reporter-manager;1"].
|
||||||
getService(Ci.nsIMemoryReporterManager);
|
getService(Ci.nsIMemoryReporterManager);
|
||||||
|
|
||||||
// Access the distinguished amounts (mgr.explicit et al.) just to make sure
|
|
||||||
// they don't crash. We can't check their actual values because they're
|
|
||||||
// non-deterministic.
|
|
||||||
//
|
|
||||||
// Nb: mgr.explicit will throw NS_ERROR_NOT_AVAILABLE if this is a
|
|
||||||
// --disable-jemalloc build. Allow for that exception, but *only* that
|
|
||||||
// exception.
|
|
||||||
let dummy;
|
|
||||||
let haveExplicit = true;
|
|
||||||
try {
|
|
||||||
dummy = mgr.explicit;
|
|
||||||
} catch (ex) {
|
|
||||||
is(ex.result, Cr.NS_ERROR_NOT_AVAILABLE, "mgr.explicit exception");
|
|
||||||
haveExplicit = false;
|
|
||||||
}
|
|
||||||
let amounts = [
|
let amounts = [
|
||||||
"vsize",
|
"vsize",
|
||||||
"vsizeMaxContiguous",
|
"vsizeMaxContiguous",
|
||||||
|
@ -182,7 +167,7 @@
|
||||||
// aren't available on all platforms. But if the attribute simply
|
// aren't available on all platforms. But if the attribute simply
|
||||||
// isn't present, that indicates the distinguished amounts have changed
|
// isn't present, that indicates the distinguished amounts have changed
|
||||||
// and this file hasn't been updated appropriately.
|
// and this file hasn't been updated appropriately.
|
||||||
dummy = mgr[amounts[i]];
|
let dummy = mgr[amounts[i]];
|
||||||
ok(dummy !== undefined,
|
ok(dummy !== undefined,
|
||||||
"accessed an unknown distinguished amount: " + amounts[i]);
|
"accessed an unknown distinguished amount: " + amounts[i]);
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
|
@ -226,9 +211,14 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If mgr.explicit failed, we won't have "heap-allocated" either.
|
try {
|
||||||
if (haveExplicit) {
|
// Nb: mgr.heapAllocated will throw NS_ERROR_NOT_AVAILABLE if this is a
|
||||||
|
// --disable-jemalloc build. Allow for skipping this test on that
|
||||||
|
// exception, but *only* that exception.
|
||||||
|
let dummy = mgr.heapAllocated;
|
||||||
checkSpecialReport("heap-allocated", heapAllocatedAmounts);
|
checkSpecialReport("heap-allocated", heapAllocatedAmounts);
|
||||||
|
} catch (ex) {
|
||||||
|
is(ex.result, Cr.NS_ERROR_NOT_AVAILABLE, "mgr.heapAllocated exception");
|
||||||
}
|
}
|
||||||
// vsize may be unreasonable if ASAN is enabled
|
// vsize may be unreasonable if ASAN is enabled
|
||||||
checkSpecialReport("vsize", vsizeAmounts, /*canBeUnreasonable*/true);
|
checkSpecialReport("vsize", vsizeAmounts, /*canBeUnreasonable*/true);
|
||||||
|
|
|
@ -205,7 +205,7 @@ interface nsIFinishReportingCallback : nsISupports
|
||||||
void callback(in nsISupports data);
|
void callback(in nsISupports data);
|
||||||
};
|
};
|
||||||
|
|
||||||
[scriptable, builtinclass, uuid(5e4eaa5a-4808-4b97-8005-e7cdc4d73693)]
|
[scriptable, builtinclass, uuid(fcad440e-64dd-4fb8-9a5e-b19d1b91423b)]
|
||||||
interface nsIMemoryReporterManager : nsISupports
|
interface nsIMemoryReporterManager : nsISupports
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@ -325,11 +325,6 @@ interface nsIMemoryReporterManager : nsISupports
|
||||||
* If you add a new distinguished amount, please update
|
* If you add a new distinguished amount, please update
|
||||||
* toolkit/components/aboutmemory/tests/test_memoryReporters.xul.
|
* toolkit/components/aboutmemory/tests/test_memoryReporters.xul.
|
||||||
*
|
*
|
||||||
* |explicit| (UNITS_BYTES) The total size of explicit memory allocations,
|
|
||||||
* both at the OS-level (eg. via mmap, VirtualAlloc) and at the heap level
|
|
||||||
* (eg. via malloc, calloc, operator new). It covers all heap allocations,
|
|
||||||
* but will miss any OS-level ones not covered by memory reporters.
|
|
||||||
*
|
|
||||||
* |vsize| (UNITS_BYTES) The virtual size, i.e. the amount of address space
|
* |vsize| (UNITS_BYTES) The virtual size, i.e. the amount of address space
|
||||||
* taken up.
|
* taken up.
|
||||||
*
|
*
|
||||||
|
@ -378,7 +373,6 @@ interface nsIMemoryReporterManager : nsISupports
|
||||||
* |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.
|
||||||
*/
|
*/
|
||||||
readonly attribute int64_t explicit;
|
|
||||||
readonly attribute int64_t vsize;
|
readonly attribute int64_t vsize;
|
||||||
readonly attribute int64_t vsizeMaxContiguous;
|
readonly attribute int64_t vsizeMaxContiguous;
|
||||||
readonly attribute int64_t resident;
|
readonly attribute int64_t resident;
|
||||||
|
|
|
@ -1944,84 +1944,6 @@ nsMemoryReporterManager::UnblockRegistrationAndRestoreOriginalReporters()
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is just a wrapper for int64_t that implements nsISupports, so it can be
|
|
||||||
// passed to nsIMemoryReporter::CollectReports.
|
|
||||||
class Int64Wrapper final : public nsISupports
|
|
||||||
{
|
|
||||||
~Int64Wrapper() {}
|
|
||||||
|
|
||||||
public:
|
|
||||||
NS_DECL_ISUPPORTS
|
|
||||||
Int64Wrapper() : mValue(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
int64_t mValue;
|
|
||||||
};
|
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS0(Int64Wrapper)
|
|
||||||
|
|
||||||
class ExplicitCallback final : public nsIHandleReportCallback
|
|
||||||
{
|
|
||||||
~ExplicitCallback() {}
|
|
||||||
|
|
||||||
public:
|
|
||||||
NS_DECL_ISUPPORTS
|
|
||||||
|
|
||||||
NS_IMETHOD Callback(const nsACString& aProcess, const nsACString& aPath,
|
|
||||||
int32_t aKind, int32_t aUnits, int64_t aAmount,
|
|
||||||
const nsACString& aDescription,
|
|
||||||
nsISupports* aWrappedExplicit) override
|
|
||||||
{
|
|
||||||
// Using the "heap-allocated" reporter here instead of
|
|
||||||
// nsMemoryReporterManager.heapAllocated goes against the usual
|
|
||||||
// pattern. But it's for a good reason: in tests, we can easily
|
|
||||||
// create artificial (i.e. deterministic) reporters -- which allows us
|
|
||||||
// to precisely test nsMemoryReporterManager.explicit -- but we can't
|
|
||||||
// do that for distinguished amounts.
|
|
||||||
if (aPath.EqualsLiteral("heap-allocated") ||
|
|
||||||
(aKind == nsIMemoryReporter::KIND_NONHEAP &&
|
|
||||||
PromiseFlatCString(aPath).Find("explicit") == 0)) {
|
|
||||||
Int64Wrapper* wrappedInt64 = static_cast<Int64Wrapper*>(aWrappedExplicit);
|
|
||||||
wrappedInt64->mValue += aAmount;
|
|
||||||
}
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS(ExplicitCallback, nsIHandleReportCallback)
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsMemoryReporterManager::GetExplicit(int64_t* aAmount)
|
|
||||||
{
|
|
||||||
if (NS_WARN_IF(!aAmount)) {
|
|
||||||
return NS_ERROR_INVALID_ARG;
|
|
||||||
}
|
|
||||||
*aAmount = 0;
|
|
||||||
#ifndef HAVE_JEMALLOC_STATS
|
|
||||||
return NS_ERROR_NOT_AVAILABLE;
|
|
||||||
#else
|
|
||||||
|
|
||||||
// For each reporter we call CollectReports and filter out the
|
|
||||||
// non-explicit, non-NONHEAP measurements (except for "heap-allocated").
|
|
||||||
// That's lots of wasted work, and we used to have a GetExplicitNonHeap()
|
|
||||||
// method which did this more efficiently, but it ended up being more
|
|
||||||
// trouble than it was worth.
|
|
||||||
|
|
||||||
nsRefPtr<ExplicitCallback> handleReport = new ExplicitCallback();
|
|
||||||
nsRefPtr<Int64Wrapper> wrappedExplicitSize = new Int64Wrapper();
|
|
||||||
|
|
||||||
// Anonymization doesn't matter here, because we're only summing all the
|
|
||||||
// reported values. Enable it anyway because it's slightly faster, since it
|
|
||||||
// doesn't have to get URLs, find notable strings, etc.
|
|
||||||
GetReportsForThisProcess(handleReport, wrappedExplicitSize,
|
|
||||||
/* anonymize = */ true);
|
|
||||||
|
|
||||||
*aAmount = wrappedExplicitSize->mValue;
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
#endif // HAVE_JEMALLOC_STATS
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsMemoryReporterManager::GetVsize(int64_t* aVsize)
|
nsMemoryReporterManager::GetVsize(int64_t* aVsize)
|
||||||
{
|
{
|
||||||
|
|
Загрузка…
Ссылка в новой задаче