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

Unified Diff: tools/deep_memory_profiler/subcommands/expand.py

Issue 692343003: dmprof expand command supports to analyze multiple components with same name in different allocators (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix conflict Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/deep_memory_profiler/lib/policy.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/deep_memory_profiler/subcommands/expand.py
diff --git a/tools/deep_memory_profiler/subcommands/expand.py b/tools/deep_memory_profiler/subcommands/expand.py
index 088b6e9d10a087328b729921006cab40e588a411..00ff3628377f4d9f260a02907d6b2b81be537d29 100644
--- a/tools/deep_memory_profiler/subcommands/expand.py
+++ b/tools/deep_memory_profiler/subcommands/expand.py
@@ -87,52 +87,60 @@ class ExpandCommand(SubCommand):
@staticmethod
def _accumulate(dump, policy, bucket_set, component_name, depth, sizes):
- rule = policy.find_rule(component_name)
- if not rule:
- pass
- elif rule.allocator_type == 'malloc':
- for bucket_id, _, committed, allocs, frees in dump.iter_stacktrace:
- bucket = bucket_set.get(bucket_id)
- if not bucket or bucket.allocator_type == 'malloc':
- component_match = policy.find_malloc(bucket)
- elif bucket.allocator_type == 'mmap':
- continue
- else:
- assert False
- if component_match == component_name:
- precedence = ''
- precedence += '(alloc=%d) ' % allocs
- precedence += '(free=%d) ' % frees
- if bucket.typeinfo:
- precedence += '(type=%s) ' % bucket.symbolized_typeinfo
- precedence += '(type.name=%s) ' % bucket.typeinfo_name
- ExpandCommand._add_size(precedence, bucket, depth, committed, sizes)
- elif rule.allocator_type == 'mmap':
- for _, region in dump.iter_map:
- if region[0] != 'hooked':
- continue
- component_match, bucket = policy.find_mmap(region, bucket_set)
- if component_match == component_name:
- ExpandCommand._add_size('', bucket, depth,
- region[1]['committed'], sizes)
- elif rule.allocator_type == 'unhooked':
- for addr, region in dump.iter_map:
- if region[0] != 'unhooked':
- continue
- component_match = policy.find_unhooked(region)
- if component_match == component_name:
- precedence = ''
- precedence += '%s-' % hex(addr[0])[2:]
- precedence += '%s' % hex(addr[1])[2:]
- precedence += ' %s' % region[1]['vma']['readable']
- precedence += '%s' % region[1]['vma']['writable']
- precedence += '%s' % region[1]['vma']['executable']
- precedence += '%s' % region[1]['vma']['private']
- precedence += ' %s' % region[1]['vma']['offset']
- precedence += ' %s:' % region[1]['vma']['major']
- precedence += '%s' % region[1]['vma']['minor']
- precedence += ' %s' % region[1]['vma']['inode']
- precedence += ' %s' % region[1]['vma']['name']
- if not precedence in sizes:
- sizes[precedence] = 0
- sizes[precedence] += region[1]['committed']
+ allocator_type = []
+ rule = None
+ while True:
+ rule = policy.find_rule(component_name, rule)
+ if not rule:
+ break
+ if rule.allocator_type not in allocator_type:
+ allocator_type.append(rule.allocator_type)
+ else:
+ continue
+
+ if rule.allocator_type == 'malloc':
+ for bucket_id, _, committed, allocs, frees in dump.iter_stacktrace:
+ bucket = bucket_set.get(bucket_id)
+ if not bucket or bucket.allocator_type == 'malloc':
+ component_match = policy.find_malloc(bucket)
+ elif bucket.allocator_type == 'mmap':
+ continue
+ else:
+ assert False
+ if component_match == component_name:
+ precedence = ''
+ precedence += '(alloc=%d) ' % allocs
+ precedence += '(free=%d) ' % frees
+ if bucket.typeinfo:
+ precedence += '(type=%s) ' % bucket.symbolized_typeinfo
+ precedence += '(type.name=%s) ' % bucket.typeinfo_name
+ ExpandCommand._add_size(precedence, bucket, depth, committed, sizes)
+ elif rule.allocator_type == 'mmap':
+ for _, region in dump.iter_map:
+ if region[0] != 'hooked':
+ continue
+ component_match, bucket = policy.find_mmap(region, bucket_set)
+ if component_match == component_name:
+ ExpandCommand._add_size('', bucket, depth,
+ region[1]['committed'], sizes)
+ elif rule.allocator_type == 'unhooked':
+ for addr, region in dump.iter_map:
+ if region[0] != 'unhooked':
+ continue
+ component_match = policy.find_unhooked(region)
+ if component_match == component_name:
+ precedence = ''
+ precedence += '%s-' % hex(addr[0])[2:]
+ precedence += '%s' % hex(addr[1])[2:]
+ precedence += ' %s' % region[1]['vma']['readable']
+ precedence += '%s' % region[1]['vma']['writable']
+ precedence += '%s' % region[1]['vma']['executable']
+ precedence += '%s' % region[1]['vma']['private']
+ precedence += ' %s' % region[1]['vma']['offset']
+ precedence += ' %s:' % region[1]['vma']['major']
+ precedence += '%s' % region[1]['vma']['minor']
+ precedence += ' %s' % region[1]['vma']['inode']
+ precedence += ' %s' % region[1]['vma']['name']
+ if not precedence in sizes:
+ sizes[precedence] = 0
+ sizes[precedence] += region[1]['committed']
« no previous file with comments | « tools/deep_memory_profiler/lib/policy.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698