Bug 1110455 - Add --sort-by=num-blocks option to dmd.py. r=mccr8.

--HG--
extra : rebase_source : 6d6aa87f102ee069f4f5052607463380c656f80d
This commit is contained in:
Nicholas Nethercote 2014-12-15 15:04:39 -08:00
parent d21eff9644
commit 30a56a2508
8 changed files with 73 additions and 16 deletions

View File

@ -148,11 +148,18 @@ class Record(object):
return cmp(abs(r1.slopSize), abs(r2.slopSize)) or \ return cmp(abs(r1.slopSize), abs(r2.slopSize)) or \
Record.cmpByIsSampled(r1, r2) 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 = { sortByChoices = {
'usable': Record.cmpByUsableSize, # the default 'usable': Record.cmpByUsableSize, # the default
'req': Record.cmpByReqSize, 'req': Record.cmpByReqSize,
'slop': Record.cmpBySlopSize, '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') help='maximum number of frames to consider in each trace')
p.add_argument('-s', '--sort-by', choices=sortByChoices.keys(), p.add_argument('-s', '--sort-by', choices=sortByChoices.keys(),
default=sortByChoices.keys()[0], default='usable',
help='sort the records by a particular metric') help='sort the records by a particular metric')
p.add_argument('-a', '--ignore-alloc-fns', action='store_true', p.add_argument('-a', '--ignore-alloc-fns', action='store_true',

View File

@ -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
}

View File

@ -30,9 +30,9 @@ Live {
} }
Live { Live {
4 blocks in heap block record 3 of 3 8 blocks in heap block record 3 of 3
16,384 bytes (8,196 requested / 8,188 slop) 16,384 bytes (8,200 requested / 8,184 slop)
Individual block sizes: 4,096 x 4 Individual block sizes: 2,048 x 8
33.32% of the heap (100.00% cumulative) 33.32% of the heap (100.00% cumulative)
Allocated at { Allocated at {
#01: C (C.cpp:99) #01: C (C.cpp:99)
@ -42,6 +42,6 @@ Live {
#----------------------------------------------------------------- #-----------------------------------------------------------------
Summary { Summary {
Total: 49,176 bytes in 14 blocks Total: 49,176 bytes in 18 blocks
} }

View File

@ -10,9 +10,9 @@ Invocation {
#----------------------------------------------------------------- #-----------------------------------------------------------------
Live { Live {
4 blocks in heap block record 1 of 3 8 blocks in heap block record 1 of 3
16,384 bytes (8,196 requested / 8,188 slop) 16,384 bytes (8,200 requested / 8,184 slop)
Individual block sizes: 4,096 x 4 Individual block sizes: 2,048 x 8
33.32% of the heap (33.32% cumulative) 33.32% of the heap (33.32% cumulative)
Allocated at { Allocated at {
#01: C (C.cpp:99) #01: C (C.cpp:99)
@ -42,6 +42,6 @@ Live {
#----------------------------------------------------------------- #-----------------------------------------------------------------
Summary { Summary {
Total: 49,176 bytes in 14 blocks Total: 49,176 bytes in 18 blocks
} }

View File

@ -30,9 +30,9 @@ Live {
} }
Live { Live {
4 blocks in heap block record 3 of 3 8 blocks in heap block record 3 of 3
16,384 bytes (8,196 requested / 8,188 slop) 16,384 bytes (8,200 requested / 8,184 slop)
Individual block sizes: 4,096 x 4 Individual block sizes: 2,048 x 8
33.32% of the heap (100.00% cumulative) 33.32% of the heap (100.00% cumulative)
Allocated at { Allocated at {
#01: C (C.cpp:99) #01: C (C.cpp:99)
@ -42,6 +42,6 @@ Live {
#----------------------------------------------------------------- #-----------------------------------------------------------------
Summary { Summary {
Total: 49,176 bytes in 14 blocks Total: 49,176 bytes in 18 blocks
} }

View File

@ -174,6 +174,8 @@ function run_test() {
["--sort-by=req", "--no-fix-stacks", jsonFile.path]); ["--sort-by=req", "--no-fix-stacks", jsonFile.path]);
test("script-sort-by-slop", test("script-sort-by-slop",
["--sort-by=slop", jsonFile.path]); ["--sort-by=slop", jsonFile.path]);
test("script-sort-by-num-blocks",
["--sort-by=num-blocks", jsonFile.path]);
// This file has several real stack traces taken from Firefox execution, each // This file has several real stack traces taken from Firefox execution, each
// of which tests a different allocator function (or functions). // of which tests a different allocator function (or functions).

View File

@ -16,6 +16,7 @@ support-files =
script-sort-by-usable-expected.txt script-sort-by-usable-expected.txt
script-sort-by-req-expected.txt script-sort-by-req-expected.txt
script-sort-by-slop-expected.txt script-sort-by-slop-expected.txt
script-sort-by-num-blocks-expected.txt
script-ignore-alloc-fns.json script-ignore-alloc-fns.json
script-ignore-alloc-fns-expected.txt script-ignore-alloc-fns-expected.txt
script-diff-live1.json script-diff-live1.json