From 5817ebf336f72786040a57a220ae9bb865b31a56 Mon Sep 17 00:00:00 2001 From: Eric Rahm Date: Tue, 30 Oct 2018 17:17:15 -0700 Subject: [PATCH] Bug 1476371 - Normalize thread names in about:memory diffs. r=njn This normalizes thread IDs (tid) to use the form 'tid=NNN'. It also normalizes threadpool numbers, for example 'Foo #1 (tid=1234)' is mapped to 'Foo #N (tid=NNN)'. --HG-- extra : rebase_source : a476da4dd81a1a34ae12170da1008a98005adf62 --- .../aboutmemory/content/aboutMemory.js | 4 ++++ .../tests/memory-reports-diff1.json | 5 ++++- .../tests/memory-reports-diff2.json | 6 ++++- .../aboutmemory/tests/test_aboutmemory3.xul | 22 +++++++++++++++++++ 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/toolkit/components/aboutmemory/content/aboutMemory.js b/toolkit/components/aboutmemory/content/aboutMemory.js index c0bc4fd13a97..2b3e3e36f050 100644 --- a/toolkit/components/aboutmemory/content/aboutMemory.js +++ b/toolkit/components/aboutmemory/content/aboutMemory.js @@ -793,6 +793,10 @@ function makeDReportMap(aJSONReports) { let process = jr.process.replace(pidRegex, pidSubst); let path = jr.path.replace(pidRegex, pidSubst); + // Strip TIDs and threadpool IDs. + path = path.replace(/\(tid=(\d+)\)/, "(tid=NNN)") + path = path.replace(/#\d+ \(tid=NNN\)/, "#N (tid=NNN)") + // Strip addresses: // - .../js-zone(0x12345678)/... // - .../zone(0x12345678)/... diff --git a/toolkit/components/aboutmemory/tests/memory-reports-diff1.json b/toolkit/components/aboutmemory/tests/memory-reports-diff1.json index 73af5a1d413b..0a7e55c323e3 100644 --- a/toolkit/components/aboutmemory/tests/memory-reports-diff1.json +++ b/toolkit/components/aboutmemory/tests/memory-reports-diff1.json @@ -40,7 +40,10 @@ {"process": "P8", "path": "p8/a/b/c/e", "kind": 2, "units": 0, "amount": 4, "description": "Desc."}, {"process": "P8", "path": "p8/a/b/f", "kind": 2, "units": 0, "amount": 5, "description": "Desc."}, {"process": "P8", "path": "p8/a/g/h", "kind": 2, "units": 0, "amount": 6, "description": "Desc."}, - {"process": "P8", "path": "p8/a/g/i", "kind": 2, "units": 0, "amount": 7, "description": "Desc."} + {"process": "P8", "path": "p8/a/g/i", "kind": 2, "units": 0, "amount": 7, "description": "Desc."}, + + {"process": "P9", "path": "explicit/threads/stacks/DNS Resolver #1 (tid=11)", "kind": 0, "units": 0, "amount": 2000, "description": "Desc."}, + {"process": "P9", "path": "explicit/threads/stacks/DNS Resolver #2 (tid=22)", "kind": 0, "units": 0, "amount": 4000, "description": "Desc."} ] } diff --git a/toolkit/components/aboutmemory/tests/memory-reports-diff2.json b/toolkit/components/aboutmemory/tests/memory-reports-diff2.json index 0e0b6f84ec87..df9899c70963 100644 --- a/toolkit/components/aboutmemory/tests/memory-reports-diff2.json +++ b/toolkit/components/aboutmemory/tests/memory-reports-diff2.json @@ -39,7 +39,11 @@ {"process": "P7", "path": "p7/c", "kind": 2, "units": 0, "amount": 4, "description": "Desc."}, {"process": "P8", "path": "p8/a/b", "kind": 2, "units": 0, "amount": 1, "description": "Desc."}, - {"process": "P8", "path": "p8/a/g", "kind": 2, "units": 0, "amount": 2, "description": "Desc."} + {"process": "P8", "path": "p8/a/g", "kind": 2, "units": 0, "amount": 2, "description": "Desc."}, + + {"process": "P9", "path": "explicit/threads/stacks/DNS Resolver #1 (tid=33)", "kind": 0, "units": 0, "amount": 2000, "description": "Desc."}, + {"process": "P9", "path": "explicit/threads/stacks/DNS Resolver #2 (tid=44)", "kind": 0, "units": 0, "amount": 4000, "description": "Desc."}, + {"process": "P9", "path": "explicit/threads/stacks/DNS Resolver #3 (tid=45)", "kind": 0, "units": 0, "amount": 5000, "description": "Desc."} ] } diff --git a/toolkit/components/aboutmemory/tests/test_aboutmemory3.xul b/toolkit/components/aboutmemory/tests/test_aboutmemory3.xul index 79216db86058..a6188da628b7 100644 --- a/toolkit/components/aboutmemory/tests/test_aboutmemory3.xul +++ b/toolkit/components/aboutmemory/tests/test_aboutmemory3.xul @@ -370,6 +370,17 @@ Other Measurements\n\ └───0.00 MB (-09.09%) ── (fake child) [!]\n\ \n\ End of P8\n\ +P9\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%) ── threads/stacks/DNS Resolver #N (tid=NNN) [3]\n\ +\n\ +Other Measurements\n\ +\n\ +End of P9\n\ "; // This is the output for a verbose diff. @@ -468,6 +479,17 @@ Other Measurements\n\ └────2 B (-09.09%) ── (fake child) [!]\n\ \n\ End of P8\n\ +P9\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\ +5,000 B (100.0%) -- explicit\n\ +└──5,000 B (100.0%) ── threads/stacks/DNS Resolver #N (tid=NNN) [3]\n\ +\n\ +Other Measurements\n\ +\n\ +End of P9\n\ "; // This is the output for the crash reports diff.