Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(395)

Side by Side Diff: tools/deep_memory_profiler/subcommands/cat.py

Issue 141563014: Make dmprof handle long runs better (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add notes to DumpList class documentation. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import json 5 import json
6 import logging 6 import logging
7 import sys 7 import sys
8 8
9 from lib.bucket import BUCKET_ID, COMMITTED, ALLOC_COUNT, FREE_COUNT 9 from lib.bucket import BUCKET_ID, COMMITTED, ALLOC_COUNT, FREE_COUNT
10 from lib.ordered_dict import OrderedDict 10 from lib.ordered_dict import OrderedDict
(...skipping 25 matching lines...) Expand all
36 alternative_dirs_dict[target_path] = host_path 36 alternative_dirs_dict[target_path] = host_path
37 (bucket_set, dumps) = SubCommand.load_basic_files( 37 (bucket_set, dumps) = SubCommand.load_basic_files(
38 dump_path, True, alternative_dirs=alternative_dirs_dict) 38 dump_path, True, alternative_dirs=alternative_dirs_dict)
39 39
40 # Load all sorters. 40 # Load all sorters.
41 sorters = SorterSet() 41 sorters = SorterSet()
42 42
43 json_root = OrderedDict() 43 json_root = OrderedDict()
44 json_root['version'] = 1 44 json_root['version'] = 1
45 json_root['run_id'] = None 45 json_root['run_id'] = None
46 for dump in dumps:
47 if json_root['run_id'] and json_root['run_id'] != dump.run_id:
48 LOGGER.error('Inconsistent heap profile dumps.')
49 json_root['run_id'] = ''
50 break
51 json_root['run_id'] = dump.run_id
52 json_root['roots'] = [] 46 json_root['roots'] = []
53 for sorter in sorters: 47 for sorter in sorters:
54 if sorter.root: 48 if sorter.root:
55 json_root['roots'].append([sorter.world, sorter.name]) 49 json_root['roots'].append([sorter.world, sorter.name])
56 json_root['default_template'] = 'l2' 50 json_root['default_template'] = 'l2'
57 json_root['templates'] = sorters.templates.as_dict() 51 json_root['templates'] = sorters.templates.as_dict()
58 52
59 orders = OrderedDict() 53 orders = OrderedDict()
60 orders['worlds'] = OrderedDict() 54 orders['worlds'] = OrderedDict()
61 for world in ['vm', 'malloc']: 55 for world in ['vm', 'malloc']:
62 orders['worlds'][world] = OrderedDict() 56 orders['worlds'][world] = OrderedDict()
63 orders['worlds'][world]['breakdown'] = OrderedDict() 57 orders['worlds'][world]['breakdown'] = OrderedDict()
64 for sorter in sorters.iter_world(world): 58 for sorter in sorters.iter_world(world):
65 order = [] 59 order = []
66 for rule in sorter.iter_rule(): 60 for rule in sorter.iter_rule():
67 if rule.name not in order: 61 if rule.name not in order:
68 order.append(rule.name) 62 order.append(rule.name)
69 orders['worlds'][world]['breakdown'][sorter.name] = order 63 orders['worlds'][world]['breakdown'][sorter.name] = order
70 json_root['orders'] = orders 64 json_root['orders'] = orders
71 65
72 json_root['snapshots'] = [] 66 json_root['snapshots'] = []
73 67
74 for dump in dumps: 68 for dump in dumps:
69 if json_root['run_id'] and json_root['run_id'] != dump.run_id:
70 LOGGER.error('Inconsistent heap profile dumps.')
71 json_root['run_id'] = ''
72 else:
73 json_root['run_id'] = dump.run_id
74
75 LOGGER.info('Sorting a dump %s...' % dump.path) 75 LOGGER.info('Sorting a dump %s...' % dump.path)
76 json_root['snapshots'].append( 76 json_root['snapshots'].append(
77 self._fill_snapshot(dump, bucket_set, sorters)) 77 self._fill_snapshot(dump, bucket_set, sorters))
78 78
79 if options.indent: 79 if options.indent:
80 json.dump(json_root, sys.stdout, indent=2) 80 json.dump(json_root, sys.stdout, indent=2)
81 else: 81 else:
82 json.dump(json_root, sys.stdout) 82 json.dump(json_root, sys.stdout)
83 print '' 83 print ''
84 84
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 int(words[ALLOC_COUNT]), 186 int(words[ALLOC_COUNT]),
187 int(words[FREE_COUNT]), 187 int(words[FREE_COUNT]),
188 bucket) 188 bucket)
189 elif not bucket: 189 elif not bucket:
190 # 'Not-found' buckets are all assumed as malloc buckets. 190 # 'Not-found' buckets are all assumed as malloc buckets.
191 yield MallocUnit(int(words[BUCKET_ID]), 191 yield MallocUnit(int(words[BUCKET_ID]),
192 int(words[COMMITTED]), 192 int(words[COMMITTED]),
193 int(words[ALLOC_COUNT]), 193 int(words[ALLOC_COUNT]),
194 int(words[FREE_COUNT]), 194 int(words[FREE_COUNT]),
195 None) 195 None)
OLDNEW
« no previous file with comments | « tools/deep_memory_profiler/lib/dump.py ('k') | tools/deep_memory_profiler/subcommands/policies.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698