author | Jan de Mooij <jdemooij@mozilla.com> |
Tue, 08 Jan 2019 15:11:08 +0000 | |
changeset 452917 | 642591e716e111cf8943cc04ff31f3110d036143 |
parent 452916 | 16e495b2c1b5fd0b22129a6d8eaefe9c333ac6b3 |
child 452918 | 270584ef33a99da992b93039d4bd63c3fc93a4d1 |
push id | 75639 |
push user | jdemooij@mozilla.com |
push date | Tue, 08 Jan 2019 15:18:18 +0000 |
treeherder | autoland@270584ef33a9 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | njn |
bugs | 1518077 |
milestone | 66.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/js/public/MemoryMetrics.h +++ b/js/public/MemoryMetrics.h @@ -953,18 +953,20 @@ class ObjectPrivateVisitor { extern JS_PUBLIC_API bool CollectGlobalStats(GlobalStats* gStats); extern JS_PUBLIC_API bool CollectRuntimeStats(JSContext* cx, RuntimeStats* rtStats, ObjectPrivateVisitor* opv, bool anonymize); +extern JS_PUBLIC_API size_t SystemCompartmentCount(JSContext* cx); +extern JS_PUBLIC_API size_t UserCompartmentCount(JSContext* cx); + extern JS_PUBLIC_API size_t SystemRealmCount(JSContext* cx); - extern JS_PUBLIC_API size_t UserRealmCount(JSContext* cx); extern JS_PUBLIC_API size_t PeakSizeOfTemporary(const JSContext* cx); extern JS_PUBLIC_API bool AddSizeOfTab(JSContext* cx, JS::HandleObject obj, mozilla::MallocSizeOf mallocSizeOf, ObjectPrivateVisitor* opv, TabSizes* sizes);
--- a/js/src/vm/MemoryMetrics.cpp +++ b/js/src/vm/MemoryMetrics.cpp @@ -814,16 +814,36 @@ JS_PUBLIC_API bool JS::CollectGlobalStat JS_PUBLIC_API bool JS::CollectRuntimeStats(JSContext* cx, RuntimeStats* rtStats, ObjectPrivateVisitor* opv, bool anonymize) { return CollectRuntimeStatsHelper(cx, rtStats, opv, anonymize, StatsCellCallback<FineGrained>); } +JS_PUBLIC_API size_t JS::SystemCompartmentCount(JSContext* cx) { + size_t n = 0; + for (CompartmentsIter comp(cx->runtime()); !comp.done(); comp.next()) { + if (IsSystemCompartment(comp)) { + ++n; + } + } + return n; +} + +JS_PUBLIC_API size_t JS::UserCompartmentCount(JSContext* cx) { + size_t n = 0; + for (CompartmentsIter comp(cx->runtime()); !comp.done(); comp.next()) { + if (!IsSystemCompartment(comp)) { + ++n; + } + } + return n; +} + JS_PUBLIC_API size_t JS::SystemRealmCount(JSContext* cx) { size_t n = 0; for (RealmsIter realm(cx->runtime()); !realm.done(); realm.next()) { if (realm->isSystem()) { ++n; } } return n;
--- a/js/xpconnect/src/XPCJSRuntime.cpp +++ b/js/xpconnect/src/XPCJSRuntime.cpp @@ -1258,16 +1258,26 @@ static int64_t JSMainRuntimeGCHeapDistin return int64_t(JS_GetGCParameter(cx, JSGC_TOTAL_CHUNKS)) * js::gc::ChunkSize; } static int64_t JSMainRuntimeTemporaryPeakDistinguishedAmount() { JSContext* cx = danger::GetJSContext(); return JS::PeakSizeOfTemporary(cx); } +static int64_t JSMainRuntimeCompartmentsSystemDistinguishedAmount() { + JSContext* cx = danger::GetJSContext(); + return JS::SystemCompartmentCount(cx); +} + +static int64_t JSMainRuntimeCompartmentsUserDistinguishedAmount() { + JSContext* cx = XPCJSContext::Get()->Context(); + return JS::UserCompartmentCount(cx); +} + static int64_t JSMainRuntimeRealmsSystemDistinguishedAmount() { JSContext* cx = danger::GetJSContext(); return JS::SystemRealmCount(cx); } static int64_t JSMainRuntimeRealmsUserDistinguishedAmount() { JSContext* cx = XPCJSContext::Get()->Context(); return JS::UserRealmCount(cx); @@ -3040,16 +3050,20 @@ void XPCJSRuntime::Initialize(JSContext* // Register memory reporters and distinguished amount functions. RegisterStrongMemoryReporter(new JSMainRuntimeRealmsReporter()); RegisterStrongMemoryReporter(new JSMainRuntimeTemporaryPeakReporter()); RegisterJSMainRuntimeGCHeapDistinguishedAmount( JSMainRuntimeGCHeapDistinguishedAmount); RegisterJSMainRuntimeTemporaryPeakDistinguishedAmount( JSMainRuntimeTemporaryPeakDistinguishedAmount); + RegisterJSMainRuntimeCompartmentsSystemDistinguishedAmount( + JSMainRuntimeCompartmentsSystemDistinguishedAmount); + RegisterJSMainRuntimeCompartmentsUserDistinguishedAmount( + JSMainRuntimeCompartmentsUserDistinguishedAmount); RegisterJSMainRuntimeRealmsSystemDistinguishedAmount( JSMainRuntimeRealmsSystemDistinguishedAmount); RegisterJSMainRuntimeRealmsUserDistinguishedAmount( JSMainRuntimeRealmsUserDistinguishedAmount); mozilla::RegisterJSSizeOfTab(JSSizeOfTab); // Set the callback for reporting memory to ubi::Node. JS::ubi::SetConstructUbiNodeForDOMObjectCallback(cx, &ConstructUbiNode);
--- a/xpcom/base/MemoryTelemetry.cpp +++ b/xpcom/base/MemoryTelemetry.cpp @@ -264,18 +264,20 @@ nsresult MemoryTelemetry::GatherReports( // The distinguished amount attribute names don't match the telemetry id // names in some cases due to a combination of (a) historical reasons, and // (b) the fact that we can't change telemetry id names without breaking // data continuity. // Collect cheap or main-thread only metrics synchronously, on the main // thread. RECORD(MEMORY_JS_GC_HEAP, JSMainRuntimeGCHeap, UNITS_BYTES); - RECORD(MEMORY_JS_COMPARTMENTS_SYSTEM, JSMainRuntimeRealmsSystem, UNITS_COUNT); - RECORD(MEMORY_JS_COMPARTMENTS_USER, JSMainRuntimeRealmsUser, UNITS_COUNT); + RECORD(MEMORY_JS_COMPARTMENTS_SYSTEM, JSMainRuntimeCompartmentsSystem, + UNITS_COUNT); + RECORD(MEMORY_JS_COMPARTMENTS_USER, JSMainRuntimeCompartmentsUser, + UNITS_COUNT); RECORD(MEMORY_IMAGES_CONTENT_USED_UNCOMPRESSED, ImagesContentUsedUncompressed, UNITS_BYTES); RECORD(MEMORY_STORAGE_SQLITE, StorageSQLite, UNITS_BYTES); #ifdef XP_WIN RECORD(LOW_MEMORY_EVENTS_VIRTUAL, LowMemoryEventsVirtual, UNITS_COUNT_CUMULATIVE); RECORD(LOW_MEMORY_EVENTS_COMMIT_SPACE, LowMemoryEventsCommitSpace, UNITS_COUNT_CUMULATIVE);
--- a/xpcom/base/nsIMemoryReporter.idl +++ b/xpcom/base/nsIMemoryReporter.idl @@ -357,16 +357,19 @@ interface nsIMemoryReporterManager : nsI * be represented by an int64_t. * * |JSMainRuntimeGCHeap| (UNITS_BYTES) Size of the main JS runtime's GC * heap. * * |JSMainRuntimeTemporaryPeak| (UNITS_BYTES) Peak size of the transient * storage in the main JSRuntime. * + * |JSMainRuntimeCompartments{System,User}| (UNITS_COUNT) The number of + * {system,user} compartments in the main JS runtime. + * * |JSMainRuntimeRealms{System,User}| (UNITS_COUNT) The number of * {system,user} realms in the main JS runtime. * * |imagesContentUsedUncompressed| (UNITS_BYTES) Memory used for decoded * raster images in content. * * |storageSQLite| (UNITS_BYTES) Memory used by SQLite. * @@ -387,16 +390,18 @@ interface nsIMemoryReporterManager : nsI [must_use] readonly attribute int64_t residentPeak; [must_use] readonly attribute int64_t residentUnique; [must_use] readonly attribute int64_t heapAllocated; [must_use] readonly attribute int64_t heapOverheadFraction; [must_use] readonly attribute int64_t JSMainRuntimeGCHeap; [must_use] readonly attribute int64_t JSMainRuntimeTemporaryPeak; + [must_use] readonly attribute int64_t JSMainRuntimeCompartmentsSystem; + [must_use] readonly attribute int64_t JSMainRuntimeCompartmentsUser; [must_use] readonly attribute int64_t JSMainRuntimeRealmsSystem; [must_use] readonly attribute int64_t JSMainRuntimeRealmsUser; [must_use] readonly attribute int64_t imagesContentUsedUncompressed; [must_use] readonly attribute int64_t storageSQLite; [must_use] readonly attribute int64_t lowMemoryEventsVirtual; @@ -484,16 +489,18 @@ typedef int64_t (*InfallibleAmountFn)(); #define DECL_REGISTER_DISTINGUISHED_AMOUNT(kind, name) \ nsresult Register##name##DistinguishedAmount(kind##AmountFn aAmountFn); #define DECL_UNREGISTER_DISTINGUISHED_AMOUNT(name) \ nsresult Unregister##name##DistinguishedAmount(); DECL_REGISTER_DISTINGUISHED_AMOUNT(Infallible, JSMainRuntimeGCHeap) DECL_REGISTER_DISTINGUISHED_AMOUNT(Infallible, JSMainRuntimeTemporaryPeak) +DECL_REGISTER_DISTINGUISHED_AMOUNT(Infallible, JSMainRuntimeCompartmentsSystem) +DECL_REGISTER_DISTINGUISHED_AMOUNT(Infallible, JSMainRuntimeCompartmentsUser) DECL_REGISTER_DISTINGUISHED_AMOUNT(Infallible, JSMainRuntimeRealmsSystem) DECL_REGISTER_DISTINGUISHED_AMOUNT(Infallible, JSMainRuntimeRealmsUser) DECL_REGISTER_DISTINGUISHED_AMOUNT(Infallible, ImagesContentUsedUncompressed) DECL_UNREGISTER_DISTINGUISHED_AMOUNT(ImagesContentUsedUncompressed) DECL_REGISTER_DISTINGUISHED_AMOUNT(Infallible, StorageSQLite) DECL_UNREGISTER_DISTINGUISHED_AMOUNT(StorageSQLite)
--- a/xpcom/base/nsMemoryReporterManager.cpp +++ b/xpcom/base/nsMemoryReporterManager.cpp @@ -2434,16 +2434,28 @@ nsMemoryReporterManager::GetJSMainRuntim } NS_IMETHODIMP nsMemoryReporterManager::GetJSMainRuntimeTemporaryPeak(int64_t* aAmount) { return GetInfallibleAmount(mAmountFns.mJSMainRuntimeTemporaryPeak, aAmount); } NS_IMETHODIMP +nsMemoryReporterManager::GetJSMainRuntimeCompartmentsSystem(int64_t* aAmount) { + return GetInfallibleAmount(mAmountFns.mJSMainRuntimeCompartmentsSystem, + aAmount); +} + +NS_IMETHODIMP +nsMemoryReporterManager::GetJSMainRuntimeCompartmentsUser(int64_t* aAmount) { + return GetInfallibleAmount(mAmountFns.mJSMainRuntimeCompartmentsUser, + aAmount); +} + +NS_IMETHODIMP nsMemoryReporterManager::GetJSMainRuntimeRealmsSystem(int64_t* aAmount) { return GetInfallibleAmount(mAmountFns.mJSMainRuntimeRealmsSystem, aAmount); } NS_IMETHODIMP nsMemoryReporterManager::GetJSMainRuntimeRealmsUser(int64_t* aAmount) { return GetInfallibleAmount(mAmountFns.mJSMainRuntimeRealmsUser, aAmount); } @@ -2696,16 +2708,19 @@ nsresult UnregisterWeakMemoryReporter(ns nsresult Unregister##name##DistinguishedAmount() { \ GET_MEMORY_REPORTER_MANAGER(mgr) \ mgr->mAmountFns.m##name = nullptr; \ return NS_OK; \ } DEFINE_REGISTER_DISTINGUISHED_AMOUNT(Infallible, JSMainRuntimeGCHeap) DEFINE_REGISTER_DISTINGUISHED_AMOUNT(Infallible, JSMainRuntimeTemporaryPeak) +DEFINE_REGISTER_DISTINGUISHED_AMOUNT(Infallible, + JSMainRuntimeCompartmentsSystem) +DEFINE_REGISTER_DISTINGUISHED_AMOUNT(Infallible, JSMainRuntimeCompartmentsUser) DEFINE_REGISTER_DISTINGUISHED_AMOUNT(Infallible, JSMainRuntimeRealmsSystem) DEFINE_REGISTER_DISTINGUISHED_AMOUNT(Infallible, JSMainRuntimeRealmsUser) DEFINE_REGISTER_DISTINGUISHED_AMOUNT(Infallible, ImagesContentUsedUncompressed) DEFINE_UNREGISTER_DISTINGUISHED_AMOUNT(ImagesContentUsedUncompressed) DEFINE_REGISTER_DISTINGUISHED_AMOUNT(Infallible, StorageSQLite) DEFINE_UNREGISTER_DISTINGUISHED_AMOUNT(StorageSQLite)
--- a/xpcom/base/nsMemoryReporterManager.h +++ b/xpcom/base/nsMemoryReporterManager.h @@ -139,16 +139,18 @@ class nsMemoryReporterManager final : pu const mozilla::dom::MemoryReport& aChildReport); void EndProcessReport(uint32_t aGeneration, bool aSuccess); // Functions that (a) implement distinguished amounts, and (b) are outside of // this module. struct AmountFns { mozilla::InfallibleAmountFn mJSMainRuntimeGCHeap; mozilla::InfallibleAmountFn mJSMainRuntimeTemporaryPeak; + mozilla::InfallibleAmountFn mJSMainRuntimeCompartmentsSystem; + mozilla::InfallibleAmountFn mJSMainRuntimeCompartmentsUser; mozilla::InfallibleAmountFn mJSMainRuntimeRealmsSystem; mozilla::InfallibleAmountFn mJSMainRuntimeRealmsUser; mozilla::InfallibleAmountFn mImagesContentUsedUncompressed; mozilla::InfallibleAmountFn mStorageSQLite; mozilla::InfallibleAmountFn mLowMemoryEventsVirtual;