зеркало из https://github.com/mozilla/gecko-dev.git
Bug 671159 - Mark entries in about:memory that come from multiple same-named memory reporters. r=jlebar.
This commit is contained in:
Родитель
ffb5db8d32
Коммит
4dfaf50493
|
@ -157,6 +157,7 @@ function update()
|
|||
// _units: number;
|
||||
// _amount: number;
|
||||
// _description: string;
|
||||
// _nMerged: number; (only defined if >= 2)
|
||||
// }
|
||||
//
|
||||
// After this point we never use the original memory reporter again.
|
||||
|
@ -182,10 +183,19 @@ function update()
|
|||
reportersByProcess[process] = {};
|
||||
}
|
||||
var reporters = reportersByProcess[process];
|
||||
if (reporters[r._path]) {
|
||||
var reporter = reporters[r._path];
|
||||
if (reporter) {
|
||||
// Already an entry; must be a duplicated reporter. This can
|
||||
// happen legitimately. Sum the values.
|
||||
reporters[r._path]._amount += r._amount;
|
||||
// happen legitimately. Sum the values (accounting for possible kUnknown
|
||||
// amounts), and mark the reporter as a dup. We mark dups because it's
|
||||
// useful to know when a reporter is duplicated; it might be worth
|
||||
// investigating and splitting up to have non-duplicated names.
|
||||
if (reporter._amount !== kUnknown && r._amount !== kUnknown) {
|
||||
reporter._amount += r._amount;
|
||||
} else if (reporter._amount === kUnknown && r._amount !== kUnknown) {
|
||||
reporter._amount = r._amount;
|
||||
}
|
||||
reporter._nMerged = reporter._nMerged ? reporter._nMerged + 1 : 2;
|
||||
} else {
|
||||
reporters[r._path] = r;
|
||||
}
|
||||
|
@ -283,13 +293,14 @@ function genProcessText(aProcess, aReporters)
|
|||
*
|
||||
* @return The built tree. The tree nodes have this structure:
|
||||
* interface Node {
|
||||
* _name: string;
|
||||
* _name: string;
|
||||
* _kind: number;
|
||||
* _amount: number; (non-negative or 'kUnknown')
|
||||
* _description: string;
|
||||
* _kids: [Node];
|
||||
* _hasReporter: boolean; (only defined if 'true')
|
||||
* _hasProblem: boolean; (only defined if 'true')
|
||||
* _nMerged: number; (only defined if >= 2)
|
||||
* }
|
||||
*/
|
||||
function buildTree()
|
||||
|
@ -307,9 +318,10 @@ function genProcessText(aProcess, aReporters)
|
|||
return undefined;
|
||||
}
|
||||
|
||||
// We want to process all reporters that begin with 'treeName'.
|
||||
// First we build the tree but only filling in '_name', '_kind', '_kids'
|
||||
// and maybe '._hasReporter'. This is done top-down from the reporters.
|
||||
// We want to process all reporters that begin with 'treeName'. First we
|
||||
// build the tree but only filling in '_name', '_kind', '_units', '_kids',
|
||||
// maybe '_hasReporter' and maybe '_nMerged'. This is done top-down from
|
||||
// the reporters.
|
||||
var t = {
|
||||
_name: "falseRoot",
|
||||
_kind: KIND_OTHER,
|
||||
|
@ -337,6 +349,9 @@ function genProcessText(aProcess, aReporters)
|
|||
}
|
||||
u._kind = r._kind;
|
||||
u._hasReporter = true;
|
||||
if (r._nMerged) {
|
||||
u._nMerged = r._nMerged;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Using falseRoot makes the above code simpler. Now discard it, leaving
|
||||
|
@ -695,19 +710,25 @@ function prepDesc(aStr)
|
|||
return escapeQuotes(flipBackslashes(aStr));
|
||||
}
|
||||
|
||||
function genMrNameText(aKind, aDesc, aName, aHasProblem)
|
||||
function genMrNameText(aKind, aDesc, aName, aHasProblem, aNMerged)
|
||||
{
|
||||
const problemDesc =
|
||||
"Warning: this memory reporter was unable to compute a useful value. " +
|
||||
"The reported value is the sum of all entries below '" + aName + "', " +
|
||||
"which is probably less than the true value.";
|
||||
var text = "-- <span class='mrName hasDesc' title='" +
|
||||
kindToString(aKind) + prepDesc(aDesc) +
|
||||
"'>" + prepName(aName) + "</span>";
|
||||
text += aHasProblem
|
||||
? " <span class='mrStar' title=\"" + problemDesc + "\">[*]</span>\n"
|
||||
: "\n";
|
||||
return text;
|
||||
if (aHasProblem) {
|
||||
const problemDesc =
|
||||
"Warning: this memory reporter was unable to compute a useful value. " +
|
||||
"The reported value is the sum of all entries below '" + aName + "', " +
|
||||
"which is probably less than the true value.";
|
||||
text += " <span class='mrStar' title=\"" + problemDesc + "\">[*]</span>";
|
||||
}
|
||||
if (aNMerged) {
|
||||
const dupDesc = "This value is the sum of " + aNMerged +
|
||||
" memory reporters that all have the same path.";
|
||||
text += " <span class='mrStar' title=\"" + dupDesc + "\">[" +
|
||||
aNMerged + "]</span>";
|
||||
}
|
||||
return text + '\n';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -791,7 +812,7 @@ function genTreeText(aT)
|
|||
|
||||
var text = indent + genMrValueText(tMemoryUsedStr) + " " + perc +
|
||||
genMrNameText(aT._kind, aT._description, aT._name,
|
||||
aT._hasProblem);
|
||||
aT._hasProblem, aT._nMerged);
|
||||
|
||||
for (var i = 0; i < aT._kids.length; i++) {
|
||||
// 3 is the standard depth, the callee adjusts it if necessary.
|
||||
|
@ -848,7 +869,8 @@ function genOtherText(aReporters)
|
|||
_units: r._units,
|
||||
_amount: hasProblem ? 0 : r._amount,
|
||||
_description: r._description,
|
||||
_hasProblem: hasProblem
|
||||
_hasProblem: hasProblem,
|
||||
_nMerged: r._nMerged
|
||||
};
|
||||
rArray.push(elem);
|
||||
var thisAmountLength = formatReporterAmount(elem).length;
|
||||
|
@ -866,7 +888,7 @@ function genOtherText(aReporters)
|
|||
text += genMrValueText(
|
||||
pad(formatReporterAmount(elem), maxAmountLength, ' ')) + " ";
|
||||
text += genMrNameText(elem._kind, elem._description, elem._path,
|
||||
elem._hasProblem);
|
||||
elem._hasProblem, elem._nMerged);
|
||||
}
|
||||
|
||||
// Nb: the newlines give nice spacing if we cut+paste into a text buffer.
|
||||
|
|
|
@ -126,7 +126,8 @@
|
|||
var fakeReporters2 = [
|
||||
f("2nd", "heap-allocated", OTHER, 1000 * MB),
|
||||
f("2nd", "heap-unallocated",OTHER, 100 * MB),
|
||||
f("2nd", "explicit/a/b/c", HEAP, 498 * MB),
|
||||
f("2nd", "explicit/a/b/c", HEAP, 497 * MB),
|
||||
f("2nd", "explicit/a/b/c", HEAP, 1 * MB), // dup: merge
|
||||
f("2nd", "explicit/a/b/c", HEAP, 1 * MB), // dup: merge
|
||||
f("2nd", "explicit/flip\\the\\backslashes",
|
||||
HEAP, 200 * MB),
|
||||
|
@ -138,12 +139,14 @@
|
|||
f("2nd", "other1", OTHER, 111 * MB),
|
||||
|
||||
// kUnknown should be handled gracefully for "heap-allocated", non-leaf
|
||||
// reporters, leaf-reporters, and "other" reporters.
|
||||
// reporters, leaf-reporters, "other" reporters, and duplicated reporters.
|
||||
f("3rd", "heap-allocated", OTHER, kUnknown),
|
||||
f("3rd", "explicit/a", HEAP, kUnknown),
|
||||
f("3rd", "explicit/a/b", HEAP, 333 * MB),
|
||||
f("3rd", "explicit/a/c", HEAP, 444 * MB),
|
||||
f("3rd", "explicit/a/c", HEAP, kUnknown), // dup: merge
|
||||
f("3rd", "explicit/a/d", HEAP, kUnknown),
|
||||
f("3rd", "explicit/a/d", HEAP, kUnknown), // dup: merge
|
||||
f("3rd", "explicit/b", NONHEAP, kUnknown),
|
||||
f("3rd", "other1", OTHER, kUnknown)
|
||||
];
|
||||
|
@ -174,13 +177,13 @@ Explicit Allocations\n\
|
|||
├──222.00 MB (35.60%) -- a\n\
|
||||
├──100.00 MB (16.04%) -- c\n\
|
||||
│ ├───77.00 MB (12.35%) -- other\n\
|
||||
│ └───23.00 MB (03.69%) -- d\n\
|
||||
├───23.00 MB (03.69%) -- cc\n\
|
||||
│ └───23.00 MB (03.69%) -- d [2]\n\
|
||||
├───23.00 MB (03.69%) -- cc [2]\n\
|
||||
├───20.00 MB (03.21%) -- f\n\
|
||||
│ └──20.00 MB (03.21%) -- g\n\
|
||||
│ └──20.00 MB (03.21%) -- h\n\
|
||||
│ └──20.00 MB (03.21%) -- i\n\
|
||||
├───15.00 MB (02.41%) -- g\n\
|
||||
├───15.00 MB (02.41%) -- g [2]\n\
|
||||
│ ├───6.00 MB (00.96%) -- a\n\
|
||||
│ ├───5.00 MB (00.80%) -- b\n\
|
||||
│ └───4.00 MB (00.64%) -- other\n\
|
||||
|
@ -202,7 +205,7 @@ Explicit Allocations\n\
|
|||
1,000.00 MB (100.0%) -- explicit\n\
|
||||
├────499.00 MB (49.90%) -- a\n\
|
||||
│ └──499.00 MB (49.90%) -- b\n\
|
||||
│ └──499.00 MB (49.90%) -- c\n\
|
||||
│ └──499.00 MB (49.90%) -- c [3]\n\
|
||||
├────200.00 MB (20.00%) -- flip/the/backslashes\n\
|
||||
├────200.00 MB (20.00%) -- compartment(this-will-be-truncated-in-non-verbose-mo...)\n\
|
||||
└────101.00 MB (10.10%) -- heap-unclassified\n\
|
||||
|
@ -218,7 +221,7 @@ Other Measurements\n\
|
|||
Explicit Allocations\n\
|
||||
777.00 MB (100.0%) -- explicit\n\
|
||||
├──777.00 MB (100.0%) -- a [*]\n\
|
||||
│ ├──444.00 MB (57.14%) -- c\n\
|
||||
│ ├──444.00 MB (57.14%) -- c [2]\n\
|
||||
│ ├──333.00 MB (42.86%) -- b\n\
|
||||
│ └────0.00 MB (00.00%) -- (1 omitted)\n\
|
||||
└────0.00 MB (00.00%) -- (2 omitted)\n\
|
||||
|
@ -244,13 +247,13 @@ Explicit Allocations\n\
|
|||
├──232,783,872 B (35.60%) -- a\n\
|
||||
├──104,857,600 B (16.04%) -- c\n\
|
||||
│ ├───80,740,352 B (12.35%) -- other\n\
|
||||
│ └───24,117,248 B (03.69%) -- d\n\
|
||||
├───24,117,248 B (03.69%) -- cc\n\
|
||||
│ └───24,117,248 B (03.69%) -- d [2]\n\
|
||||
├───24,117,248 B (03.69%) -- cc [2]\n\
|
||||
├───20,971,520 B (03.21%) -- f\n\
|
||||
│ └──20,971,520 B (03.21%) -- g\n\
|
||||
│ └──20,971,520 B (03.21%) -- h\n\
|
||||
│ └──20,971,520 B (03.21%) -- i\n\
|
||||
├───15,728,640 B (02.41%) -- g\n\
|
||||
├───15,728,640 B (02.41%) -- g [2]\n\
|
||||
│ ├───6,291,456 B (00.96%) -- a\n\
|
||||
│ ├───5,242,880 B (00.80%) -- b\n\
|
||||
│ └───4,194,304 B (00.64%) -- other\n\
|
||||
|
@ -273,7 +276,7 @@ Explicit Allocations\n\
|
|||
1,048,576,000 B (100.0%) -- explicit\n\
|
||||
├────523,239,424 B (49.90%) -- a\n\
|
||||
│ └──523,239,424 B (49.90%) -- b\n\
|
||||
│ └──523,239,424 B (49.90%) -- c\n\
|
||||
│ └──523,239,424 B (49.90%) -- c [3]\n\
|
||||
├────209,715,200 B (20.00%) -- flip/the/backslashes\n\
|
||||
├────209,715,200 B (20.00%) -- compartment(this-will-be-truncated-in-non-verbose-mode-abcdefghijklmnopqrstuvwxyz)\n\
|
||||
└────105,906,176 B (10.10%) -- heap-unclassified\n\
|
||||
|
@ -289,9 +292,9 @@ Other Measurements\n\
|
|||
Explicit Allocations\n\
|
||||
814,743,552 B (100.0%) -- explicit\n\
|
||||
├──814,743,552 B (100.0%) -- a [*]\n\
|
||||
│ ├──465,567,744 B (57.14%) -- c\n\
|
||||
│ ├──465,567,744 B (57.14%) -- c [2]\n\
|
||||
│ ├──349,175,808 B (42.86%) -- b\n\
|
||||
│ └────────────0 B (00.00%) -- d [*]\n\
|
||||
│ └────────────0 B (00.00%) -- d [*] [2]\n\
|
||||
├────────────0 B (00.00%) -- b [*]\n\
|
||||
└────────────0 B (00.00%) -- heap-unclassified [*]\n\
|
||||
\n\
|
||||
|
|
Загрузка…
Ссылка в новой задаче