mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Bug 748440 - Part 2: Report heap-committed-unused{,-ratio} in telemetry. r=taras
--HG-- extra : rebase_source : 5c864364d48a51697330b11a6ea2bcc5849d6394
This commit is contained in:
parent
1dff62b86c
commit
613652a1c9
@ -96,11 +96,13 @@ HISTOGRAM(TELEMETRY_PING, 1, 3000, 10, EXPONENTIAL, "Time taken to submit teleme
|
||||
HISTOGRAM_BOOLEAN(TELEMETRY_SUCCESS, "Successful telemetry submission")
|
||||
HISTOGRAM(MEMORY_JS_COMPARTMENTS_SYSTEM, 1, 1000, 50, EXPONENTIAL, "Total JavaScript compartments used for add-ons and internals.")
|
||||
HISTOGRAM(MEMORY_JS_COMPARTMENTS_USER, 1, 1000, 50, EXPONENTIAL, "Total JavaScript compartments used for web pages")
|
||||
HISTOGRAM(MEMORY_JS_GC_HEAP_COMMITTED, 1024, 512 * 1024, 50, EXPONENTIAL, "Committed memory used by the garbage-collected JavaScript heap (KB)")
|
||||
HISTOGRAM(MEMORY_JS_GC_HEAP, 1024, 512 * 1024, 50, EXPONENTIAL, "Memory used by the garbage-collected JavaScript heap (KB)")
|
||||
HISTOGRAM(MEMORY_RESIDENT, 32 * 1024, 1024 * 1024, 50, EXPONENTIAL, "Resident memory size (KB)")
|
||||
HISTOGRAM(MEMORY_STORAGE_SQLITE, 1024, 512 * 1024, 50, EXPONENTIAL, "Memory used by SQLite (KB)")
|
||||
HISTOGRAM(MEMORY_IMAGES_CONTENT_USED_UNCOMPRESSED, 1024, 1024 * 1024, 50, EXPONENTIAL, "Memory used for uncompressed, in-use content images (KB)")
|
||||
HISTOGRAM(MEMORY_HEAP_ALLOCATED, 1024, 1024 * 1024, 50, EXPONENTIAL, "Heap memory allocated (KB)")
|
||||
HISTOGRAM(MEMORY_HEAP_COMMITTED_UNUSED, 1024, 512 * 1024, 50, EXPONENTIAL, "Committed, unused heap memory (KB)")
|
||||
HISTOGRAM(MEMORY_HEAP_COMMITTED_UNUSED_RATIO, 1, 100, 25, LINEAR, "Ratio of committed, unused memory to allocated memory in the heap (percentage).")
|
||||
HISTOGRAM(MEMORY_EXPLICIT, 1024, 1024 * 1024, 50, EXPONENTIAL, "Explicit memory allocations (KB)")
|
||||
HISTOGRAM(GHOST_WINDOWS, 1, 128, 8, EXPONENTIAL, "Number of ghost windows")
|
||||
#if defined(XP_MACOSX)
|
||||
|
@ -54,9 +54,21 @@ const PREF_ENABLED = "toolkit.telemetry.enabled";
|
||||
const TELEMETRY_INTERVAL = 60000;
|
||||
// Delay before intializing telemetry (ms)
|
||||
const TELEMETRY_DELAY = 60000;
|
||||
// about:memory values to turn into histograms
|
||||
|
||||
// MEM_HISTOGRAMS lists the memory reporters we turn into histograms.
|
||||
//
|
||||
// Note that we currently handle only vanilla memory reporters, not memory
|
||||
// multi-reporters.
|
||||
//
|
||||
// test_TelemetryPing.js relies on some of these memory reporters
|
||||
// being here. If you remove any of the following histograms from
|
||||
// MEM_HISTOGRAMS, you'll have to modify test_TelemetryPing.js:
|
||||
//
|
||||
// * MEMORY_JS_GC_HEAP, and
|
||||
// * MEMORY_JS_COMPARTMENTS_SYSTEM.
|
||||
//
|
||||
const MEM_HISTOGRAMS = {
|
||||
"js-main-runtime-gc-heap-committed": "MEMORY_JS_GC_HEAP_COMMITTED",
|
||||
"js-gc-heap": "MEMORY_JS_GC_HEAP",
|
||||
"js-compartments-system": "MEMORY_JS_COMPARTMENTS_SYSTEM",
|
||||
"js-compartments-user": "MEMORY_JS_COMPARTMENTS_USER",
|
||||
"explicit": "MEMORY_EXPLICIT",
|
||||
@ -65,12 +77,15 @@ const MEM_HISTOGRAMS = {
|
||||
"images-content-used-uncompressed":
|
||||
"MEMORY_IMAGES_CONTENT_USED_UNCOMPRESSED",
|
||||
"heap-allocated": "MEMORY_HEAP_ALLOCATED",
|
||||
"heap-committed-unused": "MEMORY_HEAP_COMMITTED_UNUSED",
|
||||
"heap-committed-unused-ratio": "MEMORY_HEAP_COMMITTED_UNUSED_RATIO",
|
||||
"page-faults-hard": "PAGE_FAULTS_HARD",
|
||||
"low-memory-events-virtual": "LOW_MEMORY_EVENTS_VIRTUAL",
|
||||
"low-memory-events-commit-space": "LOW_MEMORY_EVENTS_COMMIT_SPACE",
|
||||
"low-memory-events-physical": "LOW_MEMORY_EVENTS_PHYSICAL",
|
||||
"ghost-windows": "GHOST_WINDOWS"
|
||||
};
|
||||
|
||||
// Seconds of idle time before pinging.
|
||||
// On idle-daily a gather-telemetry notification is fired, during it probes can
|
||||
// start asynchronous tasks to gather data. On the next idle the data is sent.
|
||||
@ -370,49 +385,60 @@ TelemetryPing.prototype = {
|
||||
let e = mgr.enumerateReporters();
|
||||
while (e.hasMoreElements()) {
|
||||
let mr = e.getNext().QueryInterface(Ci.nsIMemoryReporter);
|
||||
let id, mrPath, mrAmount, mrUnits;
|
||||
let id = MEM_HISTOGRAMS[mr.path];
|
||||
if (!id) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Reading mr.amount might throw an exception. If so, just ignore that
|
||||
// memory reporter; we're not getting useful data out of it.
|
||||
try {
|
||||
mrPath = mr.path;
|
||||
id = MEM_HISTOGRAMS[mrPath];
|
||||
if (!id) {
|
||||
continue;
|
||||
}
|
||||
mrAmount = mr.amount;
|
||||
mrUnits = mr.units;
|
||||
} catch (ex) {
|
||||
continue;
|
||||
this.handleMemoryReport(id, mr.path, mr.units, mr.amount);
|
||||
}
|
||||
|
||||
let val;
|
||||
if (mrUnits == Ci.nsIMemoryReporter.UNITS_BYTES) {
|
||||
val = Math.floor(mrAmount / 1024);
|
||||
catch (e) {
|
||||
}
|
||||
else if (mrUnits == Ci.nsIMemoryReporter.UNITS_COUNT) {
|
||||
val = mrAmount;
|
||||
}
|
||||
else if (mrUnits == Ci.nsIMemoryReporter.UNITS_COUNT_CUMULATIVE) {
|
||||
// If the reporter gives us a cumulative count, we'll report the
|
||||
// difference in its value between now and our previous ping.
|
||||
|
||||
if (!(mrPath in this._prevValues)) {
|
||||
// If this is the first time we're reading this reporter, store its
|
||||
// current value but don't report it in the telemetry ping, so we
|
||||
// ignore the effect startup had on the reporter.
|
||||
this._prevValues[mrPath] = mrAmount;
|
||||
continue;
|
||||
}
|
||||
|
||||
val = mrAmount - this._prevValues[mrPath];
|
||||
this._prevValues[mrPath] = mrAmount;
|
||||
}
|
||||
else {
|
||||
NS_ASSERT(false, "Can't handle memory reporter with units " + mrUnits);
|
||||
continue;
|
||||
}
|
||||
this.addValue(mrPath, id, val);
|
||||
}
|
||||
},
|
||||
|
||||
handleMemoryReport: function handleMemoryReport(id, path, units, amount) {
|
||||
if (amount == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
let val;
|
||||
if (units == Ci.nsIMemoryReporter.UNITS_BYTES) {
|
||||
val = Math.floor(amount / 1024);
|
||||
}
|
||||
else if (units == Ci.nsIMemoryReporter.UNITS_PERCENTAGE) {
|
||||
// UNITS_PERCENTAGE amounts are 100x greater than their raw value.
|
||||
val = Math.floor(amount / 100);
|
||||
}
|
||||
else if (units == Ci.nsIMemoryReporter.UNITS_COUNT) {
|
||||
val = amount;
|
||||
}
|
||||
else if (units == Ci.nsIMemoryReporter.UNITS_COUNT_CUMULATIVE) {
|
||||
// If the reporter gives us a cumulative count, we'll report the
|
||||
// difference in its value between now and our previous ping.
|
||||
|
||||
if (!(path in this._prevValues)) {
|
||||
// If this is the first time we're reading this reporter, store its
|
||||
// current value but don't report it in the telemetry ping, so we
|
||||
// ignore the effect startup had on the reporter.
|
||||
this._prevValues[path] = amount;
|
||||
return;
|
||||
}
|
||||
|
||||
val = amount - this._prevValues[path];
|
||||
this._prevValues[path] = amount;
|
||||
}
|
||||
else {
|
||||
NS_ASSERT(false, "Can't handle memory reporter with units " + units);
|
||||
return;
|
||||
}
|
||||
|
||||
this.addValue(path, id, val);
|
||||
},
|
||||
|
||||
/**
|
||||
* Return true if we're interested in having a STARTUP_* histogram for
|
||||
* the given histogram name.
|
||||
|
@ -186,6 +186,19 @@ function checkHistograms(request, response) {
|
||||
do_check_eq(uneval(tc),
|
||||
uneval(expected_tc));
|
||||
|
||||
// The ping should include data from memory reporters. We can't check that
|
||||
// this data is correct, because we can't control the values returned by the
|
||||
// memory reporters. But we can at least check that the data is there.
|
||||
//
|
||||
// It's important to check for the presence of reporters with a mix of units,
|
||||
// because TelemetryPing has separate logic for each one. But we can't
|
||||
// currently check UNITS_COUNT_CUMULATIVE or UNITS_PERCENTAGE because
|
||||
// Telemetry doesn't touch a memory reporter with these units that's
|
||||
// available on all platforms.
|
||||
|
||||
do_check_true('MEMORY_JS_GC_HEAP' in payload.histograms); // UNITS_BYTES
|
||||
do_check_true('MEMORY_JS_COMPARTMENTS_SYSTEM' in payload.histograms); // UNITS_COUNT
|
||||
|
||||
do_check_true(("mainThread" in payload.slowSQL) &&
|
||||
("otherThreads" in payload.slowSQL));
|
||||
gFinished = true;
|
||||
|
Loading…
Reference in New Issue
Block a user