mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
Bug 1628033 - Add pid to the main process in about:memory. r=erahm
In the tests we now explicitly use "Main Process" (or similar) for the process name in various places to avoid having to filter out a PID. Also in `test_aboutmemory[34].xhtml`, the main process entries now appear first, as they should, because the sorting code now looks for a "Main Process" prefix, rather than an exact match. Depends on D72995 Differential Revision: https://phabricator.services.mozilla.com/D73164
This commit is contained in:
parent
fe37816cbd
commit
4f86d45835
@ -69,7 +69,7 @@ let gMgr = Cc["@mozilla.org/memory-reporter-manager;1"].getService(
|
||||
const gPageName = "about:memory";
|
||||
document.title = gPageName;
|
||||
|
||||
const gUnnamedProcessStr = "Main Process";
|
||||
const gMainProcessPrefix = "Main Process";
|
||||
|
||||
const gFilterUpdateDelayMS = 300;
|
||||
|
||||
@ -1169,7 +1169,16 @@ function appendAboutMemoryMain(
|
||||
"bad presence"
|
||||
);
|
||||
|
||||
let process = aProcess === "" ? gUnnamedProcessStr : aProcess;
|
||||
// If the process is empty, that means this process -- which is the main
|
||||
// process, because this is chrome JS code -- is doing the dumping.
|
||||
// Generate the process identifier: `Main Process (pid $PID)`.
|
||||
//
|
||||
// Note that `HandleReportAndFinishReportingCallbacks::Callback()` handles
|
||||
// this when saving memory reports to file. So, if we are loading memory
|
||||
// reports from file then `aProcess` will already be non-empty.
|
||||
let process = aProcess
|
||||
? aProcess
|
||||
: gMainProcessPrefix + " (pid " + Services.appinfo.processID + ")";
|
||||
|
||||
// Store the "resident" value for each process, so that if we filter it
|
||||
// out, we can still use it to correctly sort processes and generate the
|
||||
@ -1256,10 +1265,10 @@ function appendAboutMemoryMain(
|
||||
);
|
||||
|
||||
// Always put the main process first.
|
||||
if (aProcessA == gUnnamedProcessStr) {
|
||||
if (aProcessA.startsWith(gMainProcessPrefix)) {
|
||||
return -1;
|
||||
}
|
||||
if (aProcessB == gUnnamedProcessStr) {
|
||||
if (aProcessB.startsWith(gMainProcessPrefix)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@
|
||||
let fakeReporters = [
|
||||
{ collectReports: function(aCbObj, aClosure, aAnonymize) {
|
||||
function f(aP, aK, aU, aA) {
|
||||
aCbObj.callback("", aP, aK, aU, aA, "Desc.", aClosure);
|
||||
aCbObj.callback("Main Process", aP, aK, aU, aA, "Desc.", aClosure);
|
||||
}
|
||||
f("heap-allocated", OTHER, BYTES, 500 * MB);
|
||||
f("heap-unallocated", OTHER, BYTES, 100 * MB);
|
||||
@ -79,7 +79,7 @@
|
||||
},
|
||||
{ collectReports: function(aCbObj, aClosure, aAnonymize) {
|
||||
function f(aP, aK, aU, aA) {
|
||||
aCbObj.callback("", aP, aK, aU, aA, "Desc.", aClosure);
|
||||
aCbObj.callback("Main Process", aP, aK, aU, aA, "Desc.", aClosure);
|
||||
}
|
||||
f("explicit/c/d", NONHEAP, BYTES, 13 * MB);
|
||||
f("explicit/c/d", NONHEAP, BYTES, 10 * MB); // dup
|
||||
@ -94,7 +94,7 @@
|
||||
},
|
||||
{ collectReports: function(aCbObj, aClosure, aAnonymize) {
|
||||
function f(aP, aK, aU, aA) {
|
||||
aCbObj.callback("", aP, aK, aU, aA, "Desc.", aClosure);
|
||||
aCbObj.callback("Main Process", aP, aK, aU, aA, "Desc.", aClosure);
|
||||
}
|
||||
f("other3", OTHER, COUNT, 777);
|
||||
f("other2", OTHER, BYTES, 222 * MB);
|
||||
@ -105,7 +105,7 @@
|
||||
},
|
||||
{ collectReports: function(aCbObj, aClosure, aAnonymize) {
|
||||
function f(aP) {
|
||||
aCbObj.callback("", aP, OTHER, COUNT, 1, "Desc.", aClosure);
|
||||
aCbObj.callback("Main Process", aP, OTHER, COUNT, 1, "Desc.", aClosure);
|
||||
}
|
||||
f("compartments/user/bar");
|
||||
f("compartments/system/bar");
|
||||
|
@ -38,7 +38,7 @@
|
||||
let fakeReporters = [
|
||||
{ collectReports: function(aCbObj, aClosure, aAnonymize) {
|
||||
function f(aP, aK, aA) {
|
||||
aCbObj.callback("", aP, aK, BYTES, aA, "Desc.", aClosure);
|
||||
aCbObj.callback("Main Process ABC", aP, aK, BYTES, aA, "Desc.", aClosure);
|
||||
}
|
||||
f("heap-allocated", OTHER, 250 * MB);
|
||||
f("explicit/a/b", HEAP, 50 * MB);
|
||||
@ -143,7 +143,7 @@
|
||||
|
||||
let startExpected =
|
||||
"\
|
||||
Main Process\n\
|
||||
Main Process ABC\n\
|
||||
Explicit Allocations\n\
|
||||
\n\
|
||||
250.00 MB (100.0%) -- explicit\n\
|
||||
@ -165,12 +165,12 @@ Other Measurements\n\
|
||||
\n\
|
||||
250.00 MB ── heap-allocated\n\
|
||||
\n\
|
||||
End of Main Process\n\
|
||||
End of Main Process ABC\n\
|
||||
";
|
||||
|
||||
let acCollapsedExpected =
|
||||
"\
|
||||
Main Process\n\
|
||||
Main Process ABC\n\
|
||||
Explicit Allocations\n\
|
||||
\n\
|
||||
250.00 MB (100.0%) -- explicit\n\
|
||||
@ -190,12 +190,12 @@ Other Measurements\n\
|
||||
\n\
|
||||
250.00 MB ── heap-allocated\n\
|
||||
\n\
|
||||
End of Main Process\n\
|
||||
End of Main Process ABC\n\
|
||||
";
|
||||
|
||||
let alExpandedExpected =
|
||||
"\
|
||||
Main Process\n\
|
||||
Main Process ABC\n\
|
||||
Explicit Allocations\n\
|
||||
\n\
|
||||
250.00 MB (100.0%) -- explicit\n\
|
||||
@ -217,12 +217,12 @@ Other Measurements\n\
|
||||
\n\
|
||||
250.00 MB ── heap-allocated\n\
|
||||
\n\
|
||||
End of Main Process\n\
|
||||
End of Main Process ABC\n\
|
||||
";
|
||||
|
||||
let aCollapsedExpected =
|
||||
"\
|
||||
Main Process\n\
|
||||
Main Process ABC\n\
|
||||
Explicit Allocations\n\
|
||||
\n\
|
||||
250.00 MB (100.0%) -- explicit\n\
|
||||
@ -238,12 +238,12 @@ Other Measurements\n\
|
||||
\n\
|
||||
250.00 MB ── heap-allocated\n\
|
||||
\n\
|
||||
End of Main Process\n\
|
||||
End of Main Process ABC\n\
|
||||
";
|
||||
|
||||
let hCollapsedExpected =
|
||||
"\
|
||||
Main Process\n\
|
||||
Main Process ABC\n\
|
||||
Explicit Allocations\n\
|
||||
\n\
|
||||
250.00 MB (100.0%) -- explicit\n\
|
||||
@ -257,12 +257,12 @@ Other Measurements\n\
|
||||
\n\
|
||||
250.00 MB ── heap-allocated\n\
|
||||
\n\
|
||||
End of Main Process\n\
|
||||
End of Main Process ABC\n\
|
||||
";
|
||||
|
||||
let jExpandedExpected =
|
||||
"\
|
||||
Main Process\n\
|
||||
Main Process ABC\n\
|
||||
Explicit Allocations\n\
|
||||
\n\
|
||||
250.00 MB (100.0%) -- explicit\n\
|
||||
@ -278,7 +278,7 @@ Other Measurements\n\
|
||||
\n\
|
||||
250.00 MB ── heap-allocated\n\
|
||||
\n\
|
||||
End of Main Process\n\
|
||||
End of Main Process ABC\n\
|
||||
";
|
||||
|
||||
// The important thing here is that two values have been swapped.
|
||||
@ -286,7 +286,7 @@ End of Main Process\n\
|
||||
// expanded. See bug 724863.
|
||||
let updatedExpected =
|
||||
"\
|
||||
Main Process\n\
|
||||
Main Process ABC\n\
|
||||
Explicit Allocations\n\
|
||||
\n\
|
||||
250.00 MB (100.0%) -- explicit\n\
|
||||
@ -302,12 +302,12 @@ Other Measurements\n\
|
||||
\n\
|
||||
250.00 MB ── heap-allocated\n\
|
||||
\n\
|
||||
End of Main Process\n\
|
||||
End of Main Process ABC\n\
|
||||
";
|
||||
|
||||
let aExpandedExpected =
|
||||
"\
|
||||
Main Process\n\
|
||||
Main Process ABC\n\
|
||||
Explicit Allocations\n\
|
||||
\n\
|
||||
250.00 MB (100.0%) -- explicit\n\
|
||||
@ -329,12 +329,12 @@ Other Measurements\n\
|
||||
\n\
|
||||
250.00 MB ── heap-allocated\n\
|
||||
\n\
|
||||
End of Main Process\n\
|
||||
End of Main Process ABC\n\
|
||||
";
|
||||
|
||||
let acExpandedExpected =
|
||||
"\
|
||||
Main Process\n\
|
||||
Main Process ABC\n\
|
||||
Explicit Allocations\n\
|
||||
\n\
|
||||
250.00 MB (100.0%) -- explicit\n\
|
||||
@ -358,12 +358,12 @@ Other Measurements\n\
|
||||
\n\
|
||||
250.00 MB ── heap-allocated\n\
|
||||
\n\
|
||||
End of Main Process\n\
|
||||
End of Main Process ABC\n\
|
||||
";
|
||||
|
||||
let alCollapsedExpected =
|
||||
"\
|
||||
Main Process\n\
|
||||
Main Process ABC\n\
|
||||
Explicit Allocations\n\
|
||||
\n\
|
||||
250.00 MB (100.0%) -- explicit\n\
|
||||
@ -385,7 +385,7 @@ Other Measurements\n\
|
||||
\n\
|
||||
250.00 MB ── heap-allocated\n\
|
||||
\n\
|
||||
End of Main Process\n\
|
||||
End of Main Process ABC\n\
|
||||
";
|
||||
|
||||
// Test the following cases:
|
||||
@ -401,16 +401,16 @@ End of Main Process\n\
|
||||
// upon update (and should remain expanded)
|
||||
//
|
||||
let idsToClick = [
|
||||
{ id: "measureButton", swap: 0, expected: startExpected },
|
||||
{ id: "Main Process:explicit/a/c", swap: 0, expected: acCollapsedExpected },
|
||||
{ id: "Main Process:explicit/a/l", swap: 0, expected: alExpandedExpected },
|
||||
{ id: "Main Process:explicit/a", swap: 0, expected: aCollapsedExpected },
|
||||
{ id: "Main Process:explicit/h", swap: 0, expected: hCollapsedExpected },
|
||||
{ id: "Main Process:explicit/j", swap: 0, expected: jExpandedExpected },
|
||||
{ id: "measureButton", swap: 1, expected: updatedExpected },
|
||||
{ id: "Main Process:explicit/a", swap: 0, expected: aExpandedExpected },
|
||||
{ id: "Main Process:explicit/a/c", swap: 0, expected: acExpandedExpected },
|
||||
{ id: "Main Process:explicit/a/l", swap: 0, expected: alCollapsedExpected }
|
||||
{ id: "measureButton", swap: 0, expected: startExpected },
|
||||
{ id: "Main Process ABC:explicit/a/c", swap: 0, expected: acCollapsedExpected },
|
||||
{ id: "Main Process ABC:explicit/a/l", swap: 0, expected: alExpandedExpected },
|
||||
{ id: "Main Process ABC:explicit/a", swap: 0, expected: aCollapsedExpected },
|
||||
{ id: "Main Process ABC:explicit/h", swap: 0, expected: hCollapsedExpected },
|
||||
{ id: "Main Process ABC:explicit/j", swap: 0, expected: jExpandedExpected },
|
||||
{ id: "measureButton", swap: 1, expected: updatedExpected },
|
||||
{ id: "Main Process ABC:explicit/a", swap: 0, expected: aExpandedExpected },
|
||||
{ id: "Main Process ABC:explicit/a/c", swap: 0, expected: acExpandedExpected },
|
||||
{ id: "Main Process ABC:explicit/a/l", swap: 0, expected: alCollapsedExpected }
|
||||
];
|
||||
|
||||
SimpleTest.waitForFocus(chain(idsToClick));
|
||||
|
@ -181,27 +181,6 @@
|
||||
|
||||
let expectedGood =
|
||||
"\
|
||||
Explicit-only process\n\
|
||||
\n\
|
||||
WARNING: the 'heap-allocated' memory reporter does not work for this platform and/or configuration. This means that 'heap-unclassified' is not shown and the 'explicit' tree shows less memory than it should.\n\
|
||||
Explicit Allocations\n\
|
||||
\n\
|
||||
100,000 B (100.0%) -- explicit\n\
|
||||
└──100,000 B (100.0%) ── a/b\n\
|
||||
\n\
|
||||
End of Explicit-only process\n\
|
||||
Heap-unclassified process\n\
|
||||
Explicit Allocations\n\
|
||||
\n\
|
||||
262,144,000 B (100.0%) -- explicit\n\
|
||||
├──209,715,200 B (80.00%) ── heap-unclassified\n\
|
||||
└───52,428,800 B (20.00%) ── a/b\n\
|
||||
\n\
|
||||
Other Measurements\n\
|
||||
\n\
|
||||
262,144,000 B ── heap-allocated\n\
|
||||
\n\
|
||||
End of Heap-unclassified process\n\
|
||||
Main Process (pid NNN)\n\
|
||||
Explicit Allocations\n\
|
||||
\n\
|
||||
@ -236,6 +215,27 @@ Other Measurements\n\
|
||||
262,144,000 B ── heap-allocated\n\
|
||||
\n\
|
||||
End of Main Process (pid NNN)\n\
|
||||
Explicit-only process\n\
|
||||
\n\
|
||||
WARNING: the 'heap-allocated' memory reporter does not work for this platform and/or configuration. This means that 'heap-unclassified' is not shown and the 'explicit' tree shows less memory than it should.\n\
|
||||
Explicit Allocations\n\
|
||||
\n\
|
||||
100,000 B (100.0%) -- explicit\n\
|
||||
└──100,000 B (100.0%) ── a/b\n\
|
||||
\n\
|
||||
End of Explicit-only process\n\
|
||||
Heap-unclassified process\n\
|
||||
Explicit Allocations\n\
|
||||
\n\
|
||||
262,144,000 B (100.0%) -- explicit\n\
|
||||
├──209,715,200 B (80.00%) ── heap-unclassified\n\
|
||||
└───52,428,800 B (20.00%) ── a/b\n\
|
||||
\n\
|
||||
Other Measurements\n\
|
||||
\n\
|
||||
262,144,000 B ── heap-allocated\n\
|
||||
\n\
|
||||
End of Heap-unclassified process\n\
|
||||
Other-only process\n\
|
||||
Other Measurements\n\
|
||||
\n\
|
||||
|
@ -92,27 +92,6 @@
|
||||
// the loading of data from file. If we got this far, we're doing fine.
|
||||
let expectedGood =
|
||||
"\
|
||||
Explicit-only process\n\
|
||||
\n\
|
||||
WARNING: the 'heap-allocated' memory reporter does not work for this platform and/or configuration. This means that 'heap-unclassified' is not shown and the 'explicit' tree shows less memory than it should.\n\
|
||||
Explicit Allocations\n\
|
||||
\n\
|
||||
0.10 MB (100.0%) -- explicit\n\
|
||||
└──0.10 MB (100.0%) ── a/b\n\
|
||||
\n\
|
||||
End of Explicit-only process\n\
|
||||
Heap-unclassified process\n\
|
||||
Explicit Allocations\n\
|
||||
\n\
|
||||
250.00 MB (100.0%) -- explicit\n\
|
||||
├──200.00 MB (80.00%) ── heap-unclassified\n\
|
||||
└───50.00 MB (20.00%) ── a/b\n\
|
||||
\n\
|
||||
Other Measurements\n\
|
||||
\n\
|
||||
250.00 MB ── heap-allocated\n\
|
||||
\n\
|
||||
End of Heap-unclassified process\n\
|
||||
Main Process (pid NNN)\n\
|
||||
Explicit Allocations\n\
|
||||
\n\
|
||||
@ -147,6 +126,27 @@ Other Measurements\n\
|
||||
250.00 MB ── heap-allocated\n\
|
||||
\n\
|
||||
End of Main Process (pid NNN)\n\
|
||||
Explicit-only process\n\
|
||||
\n\
|
||||
WARNING: the 'heap-allocated' memory reporter does not work for this platform and/or configuration. This means that 'heap-unclassified' is not shown and the 'explicit' tree shows less memory than it should.\n\
|
||||
Explicit Allocations\n\
|
||||
\n\
|
||||
0.10 MB (100.0%) -- explicit\n\
|
||||
└──0.10 MB (100.0%) ── a/b\n\
|
||||
\n\
|
||||
End of Explicit-only process\n\
|
||||
Heap-unclassified process\n\
|
||||
Explicit Allocations\n\
|
||||
\n\
|
||||
250.00 MB (100.0%) -- explicit\n\
|
||||
├──200.00 MB (80.00%) ── heap-unclassified\n\
|
||||
└───50.00 MB (20.00%) ── a/b\n\
|
||||
\n\
|
||||
Other Measurements\n\
|
||||
\n\
|
||||
250.00 MB ── heap-allocated\n\
|
||||
\n\
|
||||
End of Heap-unclassified process\n\
|
||||
Other-only process\n\
|
||||
Other Measurements\n\
|
||||
\n\
|
||||
|
@ -32,7 +32,7 @@
|
||||
let fakeReporters = [
|
||||
{ collectReports: function(aCbObj, aClosure, aAnonymize) {
|
||||
function f(aP, aK, aA) {
|
||||
aCbObj.callback("", aP, aK, BYTES, aA, "Desc.", aClosure);
|
||||
aCbObj.callback("Main Process", aP, aK, BYTES, aA, "Desc.", aClosure);
|
||||
}
|
||||
f("heap-allocated", OTHER, 250 * MB);
|
||||
f("explicit/a/b", HEAP, 50 * MB);
|
||||
|
@ -430,6 +430,9 @@ class HandleReportAndFinishReportingCallbacks final
|
||||
// of the form "$PROCESS_NAME (pid $PID)", or just "(pid $PID)" if we
|
||||
// don't have a process name. If we're the main process, we let
|
||||
// $PROCESS_NAME be "Main Process".
|
||||
//
|
||||
// `appendAboutMemoryMain()` in aboutMemory.js does much the same thing
|
||||
// for live memory reports.
|
||||
if (XRE_IsParentProcess()) {
|
||||
// We're the main process.
|
||||
process.AssignLiteral("Main Process");
|
||||
|
Loading…
Reference in New Issue
Block a user