From 61271da02ffefcf4085bfe401fe2453efc39aaa3 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 17 Sep 2014 21:22:57 -0700 Subject: [PATCH] Bug 1059612 - Filter diff-breaking info from memory reports in a more rigorous fashion. r=erahm. --HG-- extra : rebase_source : 373ae65ebe08a6da9ff63eb3394bc56e56d2fcfe --- .../aboutmemory/content/aboutMemory.js | 39 ++++++++++++---- .../tests/memory-reports-diff1.json | 8 +++- .../tests/memory-reports-diff2.json | 8 +++- .../aboutmemory/tests/test_aboutmemory3.xul | 44 ++++++++++++++++++- 4 files changed, 86 insertions(+), 13 deletions(-) diff --git a/toolkit/components/aboutmemory/content/aboutMemory.js b/toolkit/components/aboutmemory/content/aboutMemory.js index 90034771e7a1..b6fdedde2c5a 100644 --- a/toolkit/components/aboutmemory/content/aboutMemory.js +++ b/toolkit/components/aboutmemory/content/aboutMemory.js @@ -821,20 +821,41 @@ function makeDReportMap(aJSONReports) assert(jr.amount !== undefined, "Missing amount"); assert(jr.description !== undefined, "Missing description"); - // Strip out some non-deterministic stuff that prevents clean diffs -- - // e.g. PIDs, addresses, null principal UUIDs. (Note that we don't strip - // out all UUIDs because some of them -- such as those used by add-ons -- - // are deterministic.) + // Strip out some non-deterministic stuff that prevents clean diffs. + // Ideally the memory reports themselves would contain information about + // which parts of the the process and path need to be stripped -- saving us + // from hardwiring knowledge of specific reporters here -- but we have no + // mechanism for that. (Any future redesign of how memory reporters work + // should include such a mechanism.) + + // Strip PIDs: + // - pid 123 + // - pid=123 let pidRegex = /pid([ =])\d+/g; let pidSubst = "pid$1NNN"; - let strippedProcess = jr.process.replace(pidRegex, pidSubst); - let strippedPath = jr.path.replace(/0x[0-9A-Fa-f]+/g, "0xNNN"); - strippedPath = strippedPath.replace(pidRegex, pidSubst); - strippedPath = strippedPath.replace( + let process = jr.process.replace(pidRegex, pidSubst); + let path = jr.path.replace(pidRegex, pidSubst); + + // Strip addresses: + // - .../js-zone(0x12345678)/... + // - .../zone(0x12345678)/... + // - .../worker(, 0x12345678)/... + path = path.replace(/zone\(0x[0-9A-Fa-f]+\)\//, "zone(0xNNN)/"); + path = path.replace(/\/worker\((.+), 0x[0-9A-Fa-f]+\)\//, + "/worker($1, 0xNNN)/"); + + // Strip top window IDs: + // - explicit/window-objects/top(, id=123)/... + path = path.replace(/^(explicit\/window-objects\/top\(.*, id=)\d+\)/, + "$1NNN)"); + + // Strip null principal UUIDs (but not other UUIDs, because they may be + // deterministic, such as those used by add-ons). + path = path.replace( /moz-nullprincipal:{........-....-....-....-............}/g, "moz-nullprincipal:{NNNNNNNN-NNNN-NNNN-NNNN-NNNNNNNNNNNN}"); - let processPath = strippedProcess + kProcessPathSep + strippedPath; + let processPath = process + kProcessPathSep + path; let rOld = dreportMap[processPath]; if (rOld === undefined) { dreportMap[processPath] = diff --git a/toolkit/components/aboutmemory/tests/memory-reports-diff1.json b/toolkit/components/aboutmemory/tests/memory-reports-diff1.json index cab099475da9..b1d7bccc60d7 100644 --- a/toolkit/components/aboutmemory/tests/memory-reports-diff1.json +++ b/toolkit/components/aboutmemory/tests/memory-reports-diff1.json @@ -20,7 +20,13 @@ {"process": "P", "path": "a/c/g", "kind": 2, "units": 0, "amount": 3000000, "description": "Desc."}, {"process": "P", "path": "a/h", "kind": 2, "units": 0, "amount": 1000, "description": "Desc."}, - {"process": "P2 (pid 22)", "path": "z-moz-nullprincipal:{85e250f3-57ae-46c4-a11e-4176dd39d9c5} 0x1234-blah(0x2345) pid 123 pid=45678", "kind": 2, "units": 0, "amount": 33, "description": "Desc."}, + {"process": "P2 (pid 22)", "path": "p1 (pid 123)", "kind": 2, "units": 0, "amount": 33, "description": "Desc."}, + {"process": "P2 (pid 22)", "path": "p2 (blah, pid=123)", "kind": 2, "units": 0, "amount": 33, "description": "Desc."}, + {"process": "P2 (pid 22)", "path": "p3/zone(0x1234)/p3", "kind": 2, "units": 0, "amount": 33, "description": "Desc."}, + {"process": "P2 (pid 22)", "path": "p4/js-zone(0x1234)/p4", "kind": 2, "units": 0, "amount": 33, "description": "Desc."}, + {"process": "P2 (pid 22)", "path": "p5/worker(foo.com, 0x1234)/p5", "kind": 2, "units": 0, "amount": 33, "description": "Desc."}, + {"process": "P2 (pid 22)", "path": "explicit/window-objects/top(bar.com, id=123)/...", "kind": 0, "units": 0, "amount": 33, "description": "Desc."}, + {"process": "P2 (pid 22)", "path": "p6/z-moz-nullprincipal:{85e250f3-57ae-46c4-a11e-4176dd39d9c5}/p6", "kind": 2, "units": 0, "amount": 33, "description": "Desc."}, {"process": "P3", "path": "p3", "kind": 2, "units": 0, "amount": 55, "description": "Desc."}, diff --git a/toolkit/components/aboutmemory/tests/memory-reports-diff2.json b/toolkit/components/aboutmemory/tests/memory-reports-diff2.json index 1a060188c60b..c5bfe37adcd8 100644 --- a/toolkit/components/aboutmemory/tests/memory-reports-diff2.json +++ b/toolkit/components/aboutmemory/tests/memory-reports-diff2.json @@ -21,7 +21,13 @@ {"process": "P", "path": "a/c/g", "kind": 2, "units": 0, "amount": 3001000, "description": "Desc."}, {"process": "P", "path": "a/h", "kind": 2, "units": 0, "amount": 2000, "description": "Desc."}, - {"process": "P2 (pid 33)", "path": "z-moz-nullprincipal:{161effaa-c1f7-4010-a08e-e7c9aea01aed} 0x5678-blah(0x6789) pid 456 pid=7890", "kind": 2, "units": 0, "amount": 44, "description": "Desc."}, + {"process": "P2 (pid 22)", "path": "p1 (pid 456)", "kind": 2, "units": 0, "amount": 44, "description": "Desc."}, + {"process": "P2 (pid 22)", "path": "p2 (blah, pid=456)", "kind": 2, "units": 0, "amount": 44, "description": "Desc."}, + {"process": "P2 (pid 22)", "path": "p3/zone(0x5678)/p3", "kind": 2, "units": 0, "amount": 44, "description": "Desc."}, + {"process": "P2 (pid 22)", "path": "p4/js-zone(0x5678)/p4", "kind": 2, "units": 0, "amount": 44, "description": "Desc."}, + {"process": "P2 (pid 22)", "path": "p5/worker(foo.com, 0x5678)/p5", "kind": 2, "units": 0, "amount": 44, "description": "Desc."}, + {"process": "P2 (pid 22)", "path": "explicit/window-objects/top(bar.com, id=456)/...", "kind": 0, "units": 0, "amount": 44, "description": "Desc."}, + {"process": "P2 (pid 22)", "path": "p6/z-moz-nullprincipal:{161effaa-c1f7-4010-a08e-e7c9aea01aed}/p6", "kind": 2, "units": 0, "amount": 44, "description": "Desc."}, {"process": "P4", "path": "p4", "kind": 2, "units": 0, "amount": 66, "description": "Desc."}, diff --git a/toolkit/components/aboutmemory/tests/test_aboutmemory3.xul b/toolkit/components/aboutmemory/tests/test_aboutmemory3.xul index eb500f06326b..53b26e86375d 100644 --- a/toolkit/components/aboutmemory/tests/test_aboutmemory3.xul +++ b/toolkit/components/aboutmemory/tests/test_aboutmemory3.xul @@ -305,9 +305,29 @@ Other Measurements\n\ \n\ End of P\n\ P2 (pid NNN)\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.00 MB (100.0%) -- explicit\n\ +└──0.00 MB (100.0%) ── window-objects/top(bar.com, id=NNN)/...\n\ +\n\ Other Measurements\n\ \n\ -0.00 MB ── z-moz-nullprincipal:{NNNNNNNN-NNNN-NNNN-NNNN-NNNNNNNNNNNN} 0xNNN-blah(0xNNN) pid NNN pid=NNN\n\ +0.00 MB (100.0%) -- p3\n\ +└──0.00 MB (100.0%) ── zone(0xNNN)/p3\n\ +\n\ +0.00 MB (100.0%) -- p4\n\ +└──0.00 MB (100.0%) ── js-zone(0xNNN)/p4\n\ +\n\ +0.00 MB (100.0%) -- p5\n\ +└──0.00 MB (100.0%) ── worker(foo.com, 0xNNN)/p5\n\ +\n\ +0.00 MB (100.0%) -- p6\n\ +└──0.00 MB (100.0%) ── z-moz-nullprincipal:{NNNNNNNN-NNNN-NNNN-NNNN-NNNNNNNNNNNN}/p6\n\ +\n\ +0.00 MB ── p1 (pid NNN)\n\ +0.00 MB ── p2 (blah, pid=NNN)\n\ \n\ End of P2 (pid NNN)\n\ P3\n\ @@ -380,9 +400,29 @@ Other Measurements\n\ \n\ End of P\n\ P2 (pid NNN)\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\ +11 B (100.0%) -- explicit\n\ +└──11 B (100.0%) ── window-objects/top(bar.com, id=NNN)/...\n\ +\n\ Other Measurements\n\ \n\ -11 B ── z-moz-nullprincipal:{NNNNNNNN-NNNN-NNNN-NNNN-NNNNNNNNNNNN} 0xNNN-blah(0xNNN) pid NNN pid=NNN\n\ +11 B (100.0%) -- p3\n\ +└──11 B (100.0%) ── zone(0xNNN)/p3\n\ +\n\ +11 B (100.0%) -- p4\n\ +└──11 B (100.0%) ── js-zone(0xNNN)/p4\n\ +\n\ +11 B (100.0%) -- p5\n\ +└──11 B (100.0%) ── worker(foo.com, 0xNNN)/p5\n\ +\n\ +11 B (100.0%) -- p6\n\ +└──11 B (100.0%) ── z-moz-nullprincipal:{NNNNNNNN-NNNN-NNNN-NNNN-NNNNNNNNNNNN}/p6\n\ +\n\ +11 B ── p1 (pid NNN)\n\ +11 B ── p2 (blah, pid=NNN)\n\ \n\ End of P2 (pid NNN)\n\ P3\n\