From 30a56a2508ce0391856d5bc2e64997e0a100ddae Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 15 Dec 2014 15:04:39 -0800 Subject: [PATCH] Bug 1110455 - Add --sort-by=num-blocks option to dmd.py. r=mccr8. --HG-- extra : rebase_source : 6d6aa87f102ee069f4f5052607463380c656f80d --- memory/replace/dmd/dmd.py | 15 ++++-- .../script-sort-by-num-blocks-expected.txt | 47 ++++++++++++++++++ .../dmd/test/script-sort-by-req-expected.txt | 8 +-- .../dmd/test/script-sort-by-slop-expected.txt | 8 +-- .../test/script-sort-by-usable-expected.txt | 8 +-- .../replace/dmd/test/script-sort-by.json.gz | Bin 302 -> 305 bytes memory/replace/dmd/test/test_dmd.js | 2 + memory/replace/dmd/test/xpcshell.ini | 1 + 8 files changed, 73 insertions(+), 16 deletions(-) create mode 100644 memory/replace/dmd/test/script-sort-by-num-blocks-expected.txt diff --git a/memory/replace/dmd/dmd.py b/memory/replace/dmd/dmd.py index a7e143440a9..e6d839b6cb4 100755 --- a/memory/replace/dmd/dmd.py +++ b/memory/replace/dmd/dmd.py @@ -148,11 +148,18 @@ class Record(object): return cmp(abs(r1.slopSize), abs(r2.slopSize)) or \ Record.cmpByIsSampled(r1, r2) + @staticmethod + def cmpByNumBlocks(r1, r2): + # Sort by block counts, then by usable size. + return cmp(abs(r1.numBlocks), abs(r2.numBlocks)) or \ + Record.cmpByUsableSize(r1, r2) + sortByChoices = { - 'usable': Record.cmpByUsableSize, # the default - 'req': Record.cmpByReqSize, - 'slop': Record.cmpBySlopSize, + 'usable': Record.cmpByUsableSize, # the default + 'req': Record.cmpByReqSize, + 'slop': Record.cmpBySlopSize, + 'num-blocks': Record.cmpByNumBlocks, } @@ -185,7 +192,7 @@ variable is used to find breakpad symbols for stack fixing. help='maximum number of frames to consider in each trace') p.add_argument('-s', '--sort-by', choices=sortByChoices.keys(), - default=sortByChoices.keys()[0], + default='usable', help='sort the records by a particular metric') p.add_argument('-a', '--ignore-alloc-fns', action='store_true', diff --git a/memory/replace/dmd/test/script-sort-by-num-blocks-expected.txt b/memory/replace/dmd/test/script-sort-by-num-blocks-expected.txt new file mode 100644 index 00000000000..0f9594eb8c4 --- /dev/null +++ b/memory/replace/dmd/test/script-sort-by-num-blocks-expected.txt @@ -0,0 +1,47 @@ +#----------------------------------------------------------------- +# dmd.py --filter-stacks-for-testing -o script-sort-by-num-blocks-actual.txt --sort-by=num-blocks script-sort-by.json.gz + +Invocation { + $DMD = '--mode=live' + Mode = 'live' + Sample-below size = 1 +} + +#----------------------------------------------------------------- + +Live { + 8 blocks in heap block record 1 of 3 + 16,384 bytes (8,200 requested / 8,184 slop) + Individual block sizes: 2,048 x 8 + 33.32% of the heap (33.32% cumulative) + Allocated at { + #01: C (C.cpp:99) + } +} + +Live { + 5 blocks in heap block record 2 of 3 + 16,400 bytes (12,016 requested / 4,384 slop) + Individual block sizes: 4,096 x 4; 16 + 33.35% of the heap (66.67% cumulative) + Allocated at { + #01: B (B.cpp:99) + } +} + +Live { + 5 blocks in heap block record 3 of 3 + 16,392 bytes (16,392 requested / 0 slop) + Individual block sizes: 4,096 x 4; 8 + 33.33% of the heap (100.00% cumulative) + Allocated at { + #01: A (A.cpp:99) + } +} + +#----------------------------------------------------------------- + +Summary { + Total: 49,176 bytes in 18 blocks +} + diff --git a/memory/replace/dmd/test/script-sort-by-req-expected.txt b/memory/replace/dmd/test/script-sort-by-req-expected.txt index b054a6f5381..9bc2ebfa22b 100644 --- a/memory/replace/dmd/test/script-sort-by-req-expected.txt +++ b/memory/replace/dmd/test/script-sort-by-req-expected.txt @@ -30,9 +30,9 @@ Live { } Live { - 4 blocks in heap block record 3 of 3 - 16,384 bytes (8,196 requested / 8,188 slop) - Individual block sizes: 4,096 x 4 + 8 blocks in heap block record 3 of 3 + 16,384 bytes (8,200 requested / 8,184 slop) + Individual block sizes: 2,048 x 8 33.32% of the heap (100.00% cumulative) Allocated at { #01: C (C.cpp:99) @@ -42,6 +42,6 @@ Live { #----------------------------------------------------------------- Summary { - Total: 49,176 bytes in 14 blocks + Total: 49,176 bytes in 18 blocks } diff --git a/memory/replace/dmd/test/script-sort-by-slop-expected.txt b/memory/replace/dmd/test/script-sort-by-slop-expected.txt index 10d94ace5b6..9e423704af8 100644 --- a/memory/replace/dmd/test/script-sort-by-slop-expected.txt +++ b/memory/replace/dmd/test/script-sort-by-slop-expected.txt @@ -10,9 +10,9 @@ Invocation { #----------------------------------------------------------------- Live { - 4 blocks in heap block record 1 of 3 - 16,384 bytes (8,196 requested / 8,188 slop) - Individual block sizes: 4,096 x 4 + 8 blocks in heap block record 1 of 3 + 16,384 bytes (8,200 requested / 8,184 slop) + Individual block sizes: 2,048 x 8 33.32% of the heap (33.32% cumulative) Allocated at { #01: C (C.cpp:99) @@ -42,6 +42,6 @@ Live { #----------------------------------------------------------------- Summary { - Total: 49,176 bytes in 14 blocks + Total: 49,176 bytes in 18 blocks } diff --git a/memory/replace/dmd/test/script-sort-by-usable-expected.txt b/memory/replace/dmd/test/script-sort-by-usable-expected.txt index 4f5384ebb52..48b6476416e 100644 --- a/memory/replace/dmd/test/script-sort-by-usable-expected.txt +++ b/memory/replace/dmd/test/script-sort-by-usable-expected.txt @@ -30,9 +30,9 @@ Live { } Live { - 4 blocks in heap block record 3 of 3 - 16,384 bytes (8,196 requested / 8,188 slop) - Individual block sizes: 4,096 x 4 + 8 blocks in heap block record 3 of 3 + 16,384 bytes (8,200 requested / 8,184 slop) + Individual block sizes: 2,048 x 8 33.32% of the heap (100.00% cumulative) Allocated at { #01: C (C.cpp:99) @@ -42,6 +42,6 @@ Live { #----------------------------------------------------------------- Summary { - Total: 49,176 bytes in 14 blocks + Total: 49,176 bytes in 18 blocks } diff --git a/memory/replace/dmd/test/script-sort-by.json.gz b/memory/replace/dmd/test/script-sort-by.json.gz index 6a68f955dcb54deb8196208823b61cecca05b7d9..6f0232aefcf53a6d36dd99d8d8ebefd2192326a7 100644 GIT binary patch literal 305 zcmV-10nYv(iwFq&GmcaM19M|?X>fEcb8m8VEn;~tYIARH0PT}8Ps1<}g?Imo)3F38 zMQ#HXiNs)AY-}JFl)+7m6yd}niGoDb|Bf#$A?wO^ zUH0}+w4I;5ceva3q0cy=iDD}t*hxJi!gZ__D9U? z?f9sZwJ^`!d~-98-bC|gwTS*VpJQf_(#P)_otY=Sv*x>0f+~PQU^;e2j#A2_RHIZ1 z(_?d98(l5}C;=}xPe4E*uClsL;`s7VK`AFFA&{p~sR=3w)CB!iY|p*`^#Y&969fPN DBBP97 literal 302 zcmV+}0nz>+iwFpE$cIz_19M|?X>fEcb8m8VEn;~tYIARH0L_v?PlPZKh41|plktKH zYr5`c6%r3^Y zUUn|k?QzmG0L+T)vFu)T?FYD86)rOmHt!6EL`f1jPa0iR)<|RB*K__&aLwRA*?a5K zkEgt8{p`(Kd#uf;zi)Z83jwwDoU#Ox{WADI1b-HI!Z)0A|GcrTqD>ZIavt_i%