diff options
author | dmikurube@chromium.org <dmikurube@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-13 11:44:49 +0000 |
---|---|---|
committer | dmikurube@chromium.org <dmikurube@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-13 11:44:49 +0000 |
commit | c46965928ecaedf3f96e3d8f203fac8f6b2125ed (patch) | |
tree | 1e383463bdceed4ea8fdc7d252296ea5e2ada39b /tools/deep_memory_profiler | |
parent | 5571d642d81495e2fc958abe2e320604a044b1ef (diff) | |
download | chromium_src-c46965928ecaedf3f96e3d8f203fac8f6b2125ed.zip chromium_src-c46965928ecaedf3f96e3d8f203fac8f6b2125ed.tar.gz chromium_src-c46965928ecaedf3f96e3d8f203fac8f6b2125ed.tar.bz2 |
Breakdown nonprofiled memory regions (f.k.a. 'unknown'), and add new policy files.
It breaks down nonprofiled memory regions (f.k.a. 'unknown') with using information
from /proc/(pid)/maps.
'mustbezero' and 'nonprofiled-*' columns show broken down values.
- mustbezero: works as a sentinel value. it should be '0'. tell dmikurube@ if it > 0.
- nonprofiled-absent: works as a sentinel value. should be '0'.
- nonprofiled-anonymous: may be still 'unknown'. no special info from maps.
- nonprofiled-file-exec: is a mapped file here as executable.
- nonprofiled-file-nonexec: is a mapped file here as non-executable.
- nonprofiled-stack: is a stack.
- nonprofiled-other: includes [vdso] and some small portions.
It also removes dmpolicy (an old one) and adds new policy files: policy.l{0-2}.txt.
The new files 'policy.l{0-2}.txt' are recommended instead of 'dmpolicy'.
policy.l0.txt is the roughest, and policy.l2.txt is the finest breakdown.
We can check that summation from 'FROM_HERE_FOR_TOTAL' till 'UNTIL_HERE_FOR_TOTAL'
is equal to 'total-exclude-profiler'.
Finally, dmprof.py is renamed into dmprof like pprof in tcmalloc.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/9812010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132174 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/deep_memory_profiler')
-rw-r--r-- | tools/deep_memory_profiler/README.policy | 56 | ||||
-rw-r--r-- | tools/deep_memory_profiler/dmpolicy | 109 | ||||
-rwxr-xr-x | tools/deep_memory_profiler/dmprof (renamed from tools/deep_memory_profiler/dmprof.py) | 235 | ||||
-rw-r--r-- | tools/deep_memory_profiler/policy.l0.txt | 34 | ||||
-rw-r--r-- | tools/deep_memory_profiler/policy.l1.txt | 41 | ||||
-rw-r--r-- | tools/deep_memory_profiler/policy.l2.txt | 87 |
6 files changed, 365 insertions, 197 deletions
diff --git a/tools/deep_memory_profiler/README.policy b/tools/deep_memory_profiler/README.policy new file mode 100644 index 0000000..48ad957 --- /dev/null +++ b/tools/deep_memory_profiler/README.policy @@ -0,0 +1,56 @@ +Policy files contains a classification policy for dmprof.py. + +Each line indicates a group to be classified and conditions for classifying +in the following format. + Format: <group-name> <region-type> <pattern> + +<group-name> is a name for the group to be classified. Same names can appear +in the same policy file multiple times. <region-type> represents a type of +the memory region. It's one of {malloc, mmap, default, optional}. <pattern> +is a Python-style regular expression to match with calling stack frames. + +For each memory chunks allocated by malloc, its calling stack frame of malloc +is compared with these classification policies whose <region-type> is 'malloc' +from the top. If <pattern> of the policy matches the frame, the memory chunk +is classified into <group-name>. The same way for 'mmap'. + +Policy lines whose <region-type>s are 'optional' and 'default' are used by +dmprof.py internally. 'optional' policies can be disabled by removing or +commenting-out. + + +Guidelines to write a new policy. + +Better policies would classify memory on a single layer, or simple combination +of layers. For example, +- Large-level components (V8, WebKit, ...) +- Mid-level components (Font, FileAPI, ...) +- Low-level libraries (StringImpl, HashTable, ...) +- Mid-level libraries (SharedBuf, XHR, ...) + +For example of combinations, +- How about SharedBuf in Font API v.s. other APIs? +- How about Strings in IndexedDB v.s. File APIs? + + +Deprecated policies for references. + +total-vm optional optional +anonymous-vm optional optional +filemapped-vm optional optional +other-vm optional optional +vm-profiler optional optional +vm-total optional optional +mmap-v8-heap-new mmap .*v8::.*::ReserveInitialChunk.* +mmap-v8-heap-coderange mmap .*v8::.*::CodeRange::Setup.* +mmap-v8-heap-old-evacuate mmap .*v8::.*::OldSpace::.* v8::internal::ScavengingVisitor::EvacuateObject.* +mmap-v8-heap-old mmap .*v8::.*::OldSpace::.* +mmap-v8-heap-largeobj mmap .*v8::.*::LargeObjectChunk::New.* +mmap-v8-heap-other mmap .*VirtualMemory.* +mmap-v8-heap-other mmap .*v8::internal::OS::Allocate.* +mmap-v8-nonheap mmap .*v8::.* +mmap-webkit mmap .*(WTF::|WebCore::|WebKit::).* +mmap-sqlite mmap .*sqlite3MemMalloc.* +mmap-pl-arena mmap .*PL_ArenaAllocate.* +mmap-sk mmap .*sk_malloc_flags.* +mmap-total-record-vm default default diff --git a/tools/deep_memory_profiler/dmpolicy b/tools/deep_memory_profiler/dmpolicy deleted file mode 100644 index cb46ba0..0000000 --- a/tools/deep_memory_profiler/dmpolicy +++ /dev/null @@ -1,109 +0,0 @@ -heap profile policy: POLICY_DEEP_2 -# -# This file contains a classification policy for dmprof.py. -# -# Each line indicates a group to be classified and conditions for classifying -# in the following format. -# Format: <group-name> <region-type> <pattern> -# -# <group-name> is a name for the group to be classified. Same names can appear -# in the same policy file multiple times. <region-type> represents a type of -# the memory region. It's one of {malloc, mmap, default, optional}. <pattern> -# is a Python-style regular expression to match with calling stack frames. -# -# For each memory chunks allocated by malloc, its calling stack frame of malloc -# is compared with these classification policies whose <region-type> is 'malloc' -# from the top. If <pattern> of the policy matches the frame, the memory chunk -# is classified into <group-name>. The same way for 'mmap'. -# -# Policy lines whose <region-type>s are 'optional' and 'default' are used by -# dmprof.py internally. 'optional' policies can be disabled by removing or -# commenting-out. -# -second optional optional -minute optional optional -unknown optional optional -total-exclude-profiler optional optional -#total optional optional -#anonymous optional optional -#filemapped optional optional -#other optional optional -#total-vm optional optional -#anonymous-vm optional optional -#filemapped-vm optional optional -#other-vm optional optional -#vm-profiler optional optional -#vm-total optional optional -no-bucket default default -mmap-profiler mmap .*(ProfilerMalloc|MemoryRegionMap::).* -mmap-tcmalloc mmap .*(DoAllocWithArena|SbrkSysAllocator::Alloc|MmapSysAllocator::Alloc|LowLevelAlloc::Alloc|LowLevelAlloc::AllocWithArena).* -mmap-v8-heap-new mmap .*v8::.*::ReserveInitialChunk.* -mmap-v8-heap-coderange mmap .*v8::.*::CodeRange::Setup.* -mmap-v8-heap-old-evacuate mmap .*v8::.*::OldSpace::.* v8::internal::ScavengingVisitor::EvacuateObject.* -mmap-v8-heap-old mmap .*v8::.*::OldSpace::.* -mmap-v8-heap-largeobj mmap .*v8::.*::LargeObjectChunk::New.* -mmap-v8-heap-other mmap .*VirtualMemory.* -mmap-v8-heap-other mmap .*v8::internal::OS::Allocate.* -mmap-v8-nonheap mmap .*v8::.* -#mmap-webkit mmap .*(WTF::|WebCore::|WebKit::).* -#mmap-sqlite mmap .*sqlite3MemMalloc.* -#mmap-pl-arena mmap .*PL_ArenaAllocate.* -#mmap-sk mmap .*sk_malloc_flags.* -mmap-no-policy mmap .* -mmap-total-log default default -mmap-no-log default default -mmap-total-record default default -#mmap-total-record-vm default default -tc-webcore-attreventlistener malloc .*WebCore::createAttributeEventListener.* -tc-webcore-v8lazyeventlistener malloc .*WebCore::V8LazyEventListener::create.* -tc-webcore-v8eventlistener malloc .*WebCore::V8EventListener::create.* -tc-v8-heap malloc .*v8::.*::ReserveInitialChunk.* -tc-v8-heap malloc .*v8::.*::CodeRange::Setup.* -tc-v8-heap malloc .*v8::.*::OldSpace::.* -tc-v8-heap malloc .*v8::.*::LargeObjectChunk::New.* -tc-v8-heap malloc .*VirtualMemory.* -tc-v8-heap malloc .*v8::internal::OS::Allocate.* -tc-webcore-event malloc .*WebCore::Event::create .* -tc-webcore-document malloc .*WebCore::Document::create .* -tc-webcore-node malloc .*WebCore::Node::create .* -tc-webcore-eventlistener malloc .*WebCore::EventListener::create .* -tc-wtf-stringimpl malloc .*WTF::StringImpl::create .* -tc-webcore-cachedresource malloc .*WebCore::CachedResource::load .* -tc-webcore-domwindow malloc .*WebCore::DOMWindow::create .* -tc-webkit-shrinkToFit malloc .*WTF::StringImpl::createUninitialized WTF::StringBuilder::shrinkToFit WebCore::XMLHttpRequest::didFinishLoading.* -tc-webkit-StringImpl12 malloc .*WTF::StringImpl::createUninitialized WTF::StringBuilder::shrinkToFit WTF::StringBuilder::toString.* -tc-webkit-KURLgoogle-v8 malloc .*WTF::StringImpl::createUninitialized WTF::StringImpl::create String WebCore::KURLGooglePrivate::string WebCore::KURL::string WTF::String WebCore::V8XMLHttpRequest::sendCallback.* -tc-webkit-KURLgoogle malloc .*WTF::StringImpl::createUninitialized WTF::StringImpl::create String WebCore::KURLGooglePrivate::string.* -tc-webkit-StringAMTB malloc .*WTF::StringImpl::createUninitialized WTF::StringImpl::create String WebCore::AtomicMarkupTokenBase::.* -tc-webkit-StringImpl2 malloc .*WTF::StringImpl::createUninitialized WTF::StringImpl::create.* -tc-webkit-StringImpl3 malloc .*WTF::StringImpl::createUninitialized WTF::String::append.* -tc-webkit-StringImpl4 malloc .*WTF::StringImpl::createUninitialized WTF::String::fromUTF8.* -tc-webkit-StringImpl5 malloc .*WTF::StringImpl::createUninitialized WTF::StringBuilder::allocateBuffer.* -tc-webkit-StringImpl6 malloc .*WTF::StringImpl::createUninitialized WTF::String::createUninitialized.* -tc-webkit-StringImpl7 malloc .*WTF::StringImpl::createUninitialized WTF::StringImpl::upper.* -tc-webkit-StringImpl8 malloc .*WTF::StringImpl::createUninitialized WTF::StringImpl::replace.* -tc-webkit-StringImpl malloc .*WTF::StringImpl::createUninitialized.* -tc-webkit-htmlElement malloc .*WebCore::HTMLElementFactory::createHTMLElement.* -tc-webkit-htmlAttribute malloc .*WebCore::Element::setAttributeMap.* -tc-webkit-atomicHTMLToken malloc .*AtomicHTMLToken.* -tc-webkit-htmltree malloc .*WebCore::HTMLTreeBuilder::constructTreeFromToken.* -tc-webkit-hashtable malloc .*WTF::HashTable::allocateTable .* -tc-webkit-operator malloc .*WTF::fastMalloc WTF::\S*::operator .* -tc-webkit-fastmalloc malloc .*WTF::fastMalloc .* -tc-v8-malloced malloc .*v8::internal::Malloced::New.* -tc-v8-nonheap malloc .*v8::.* -tc-webkit malloc .*(WTF::|WebCore::|WebKit::).* -tc-ftmemqalloc malloc .*ft_mem_qalloc.* -tc-pixman malloc .*pixman_image_create_bits.* -tc-stdstring malloc .*std::string::_Rep::_S_create.* -tc-gnualloc-rbtree malloc .*__gnu_cxx::new_allocator::allocate std::_Rb_tree::.* -tc-gnualloc malloc .*__gnu_cxx::new_allocator::allocate.* -tc-sqlite malloc .*sqlite3MemMalloc.* -tc-sk malloc .*sk_malloc_flags.* -tc-no-policy malloc .* -tc-total-log default default -tc-no-log default default -tc-total-record default default -tc-unused default default -tc-total default default -other-total-log default default diff --git a/tools/deep_memory_profiler/dmprof.py b/tools/deep_memory_profiler/dmprof index e9c642c..fdf5a7c 100755 --- a/tools/deep_memory_profiler/dmprof.py +++ b/tools/deep_memory_profiler/dmprof @@ -45,6 +45,11 @@ DUMP_DEEP_2 = 'DUMP_DEEP_2' # They should be processed by POLICY_DEEP_2. DUMP_DEEP_3 = 'DUMP_DEEP_3' +# DUMP_DEEP_4 adds some features to DUMP_DEEP_3: +# 1. Support comments starting with '#' +# 2. Support additional global stats: e.g. nonprofiled-*. +DUMP_DEEP_4 = 'DUMP_DEEP_4' + # Heap Profile Policy versions # POLICY_DEEP_1 DOES NOT include allocation_type columns. @@ -109,8 +114,8 @@ class Log(object): """A class representing one dumped log data.""" def __init__(self, log_path, buckets): self.log_path = log_path - with open(self.log_path, mode='r') as log_f: - self.log_lines = log_f.readlines() + self.log_lines = [ + l for l in open(self.log_path, 'r') if l and not l.startswith('#')] self.log_version = '' sys.stderr.write('parsing a log file:%s\n' % log_path) self.mmap_stacktrace_lines = [] @@ -282,28 +287,30 @@ class Log(object): return line_number return line_number - def parse_stacktraces_while_valid(self, buckets, log_lines, ln): + def parse_stacktraces_while_valid(self, buckets, log_lines, line_number): """Parses stacktrace lines while the lines are valid. Args: buckets: A dict mapping bucket ids and their corresponding Bucket objects. log_lines: A list of lines to be parsed. - ln: An integer representing the starting line number in log_lines. + line_number: An integer representing the starting line number in + log_lines. Returns: A pair of a list of valid lines and an integer representing the last line number in log_lines. """ - ln = self.skip_lines_while( - ln, len(log_lines), lambda n: not log_lines[n].split()[0].isdigit()) - stacktrace_lines_start = ln - ln = self.skip_lines_while( - ln, len(log_lines), + line_number = self.skip_lines_while( + line_number, len(log_lines), + lambda n: not log_lines[n].split()[0].isdigit()) + stacktrace_lines_start = line_number + line_number = self.skip_lines_while( + line_number, len(log_lines), lambda n: self.check_stacktrace_line(log_lines[n], buckets)) - return (log_lines[stacktrace_lines_start:ln], ln) + return (log_lines[stacktrace_lines_start:line_number], line_number) - def parse_stacktraces(self, buckets): + def parse_stacktraces(self, buckets, line_number): """Parses lines in self.log_lines as stacktrace. Valid stacktrace lines are stored into self.mmap_stacktrace_lines and @@ -312,10 +319,81 @@ class Log(object): Args: buckets: A dict mapping bucket ids and their corresponding Bucket objects. + line_number: An integer representing the starting line number in + log_lines. + + Raises: + RuntimeException for invalid dump versions. + """ + sys.stderr.write(' heap profile dump version: %s\n' % self.log_version) + + if self.log_version in (DUMP_DEEP_3, DUMP_DEEP_4): + (self.mmap_stacktrace_lines, line_number) = ( + self.parse_stacktraces_while_valid( + buckets, self.log_lines, line_number)) + line_number = self.skip_lines_while( + line_number, len(self.log_lines), + lambda n: self.log_lines[n] != 'MALLOC_STACKTRACES:\n') + (self.malloc_stacktrace_lines, line_number) = ( + self.parse_stacktraces_while_valid( + buckets, self.log_lines, line_number)) + + elif self.log_version == DUMP_DEEP_2: + (self.mmap_stacktrace_lines, line_number) = ( + self.parse_stacktraces_while_valid( + buckets, self.log_lines, line_number)) + line_number = self.skip_lines_while( + line_number, len(self.log_lines), + lambda n: self.log_lines[n] != 'MALLOC_STACKTRACES:\n') + (self.malloc_stacktrace_lines, line_number) = ( + self.parse_stacktraces_while_valid( + buckets, self.log_lines, line_number)) + self.malloc_stacktrace_lines.extend(self.mmap_stacktrace_lines) + self.mmap_stacktrace_lines = [] + + elif self.log_version == DUMP_DEEP_1: + (self.malloc_stacktrace_lines, line_number) = ( + self.parse_stacktraces_while_valid( + buckets, self.log_lines, line_number)) + + else: + raise RuntimeError('invalid heap profile dump version: %s' % ( + self.log_version)) + + def parse_global_stats(self): + """Parses lines in self.log_lines as global stats.""" + ln = self.skip_lines_while( + 0, len(self.log_lines), + lambda n: self.log_lines[n] != 'GLOBAL_STATS:\n') + + if self.log_version == DUMP_DEEP_4: + global_stat_names = [ + 'total', 'file-exec', 'file-nonexec', 'anonymous', 'stack', 'other', + 'nonprofiled-absent', 'nonprofiled-anonymous', + 'nonprofiled-file-exec', 'nonprofiled-file-nonexec', + 'nonprofiled-stack', 'nonprofiled-other', + 'profiled-mmap', 'profiled-malloc'] + else: + global_stat_names = [ + 'total', 'file', 'anonymous', 'other', 'mmap', 'tcmalloc'] + + for prefix in global_stat_names: + ln = self.skip_lines_while( + ln, len(self.log_lines), + lambda n: self.log_lines[n].split()[0] != prefix) + words = self.log_lines[ln].split() + self.counters[prefix + '_virtual'] = int(words[-2]) + self.counters[prefix + '_committed'] = int(words[-1]) + + def parse_version(self): + """Parses a version string in self.log_lines. Returns: - A string representing a version of the stacktrace dump. '' for invalid - dump. + A pair of (a string representing a version of the stacktrace dump, + and an integer indicating a line number next to the version string). + + Raises: + RuntimeException for invalid dump versions. """ version = '' @@ -328,69 +406,24 @@ class Log(object): # Identify a version. if self.log_lines[ln].startswith('heap profile: '): version = self.log_lines[ln][13:].strip() - if version == DUMP_DEEP_2 or version == DUMP_DEEP_3: + if (version == DUMP_DEEP_2 or version == DUMP_DEEP_3 or + version == DUMP_DEEP_4): ln = self.skip_lines_while( ln, len(self.log_lines), lambda n: self.log_lines[n] != 'MMAP_STACKTRACES:\n') else: - sys.stderr.write(' invalid heap profile dump version:%s\n' % version) - return '' + raise RuntimeError('invalid heap profile dump version: %s' % version) elif self.log_lines[ln] == 'STACKTRACES:\n': version = DUMP_DEEP_1 elif self.log_lines[ln] == 'MMAP_STACKTRACES:\n': version = DUMP_DEEP_2 - if version == DUMP_DEEP_3: - sys.stderr.write(' heap profile dump version: %s\n' % version) - (self.mmap_stacktrace_lines, ln) = self.parse_stacktraces_while_valid( - buckets, self.log_lines, ln) - ln = self.skip_lines_while( - ln, len(self.log_lines), - lambda n: self.log_lines[n] != 'MALLOC_STACKTRACES:\n') - (self.malloc_stacktrace_lines, ln) = self.parse_stacktraces_while_valid( - buckets, self.log_lines, ln) - return version - - elif version == DUMP_DEEP_2: - sys.stderr.write(' heap profile dump version: %s\n' % version) - (self.mmap_stacktrace_lines, ln) = self.parse_stacktraces_while_valid( - buckets, self.log_lines, ln) - ln = self.skip_lines_while( - ln, len(self.log_lines), - lambda n: self.log_lines[n] != 'MALLOC_STACKTRACES:\n') - (self.malloc_stacktrace_lines, ln) = self.parse_stacktraces_while_valid( - buckets, self.log_lines, ln) - self.malloc_stacktrace_lines.extend(self.mmap_stacktrace_lines) - self.mmap_stacktrace_lines = [] - return version - - elif version == DUMP_DEEP_1: - sys.stderr.write(' heap profile dump version: %s\n' % version) - (self.malloc_stacktrace_lines, ln) = self.parse_stacktraces_while_valid( - buckets, self.log_lines, ln) - return version - - else: - sys.stderr.write(' invalid heap profile dump version:%s\n' % version) - return '' - - def parse_global_stats(self): - """Parses lines in self.log_lines as global stats.""" - ln = self.skip_lines_while( - 0, len(self.log_lines), - lambda n: self.log_lines[n] != 'GLOBAL_STATS:\n') - - for prefix in ['total', 'file', 'anonymous', 'other', 'mmap', 'tcmalloc']: - ln = self.skip_lines_while( - ln, len(self.log_lines), - lambda n: self.log_lines[n].split()[0] != prefix) - words = self.log_lines[ln].split() - self.counters[prefix + '_virtual'] = int(words[-2]) - self.counters[prefix + '_committed'] = int(words[-1]) + return (version, ln) def parse_log(self, buckets): + self.log_version, ln = self.parse_version() self.parse_global_stats() - self.log_version = self.parse_stacktraces(buckets) + self.parse_stacktraces(buckets, ln) @staticmethod def accumulate_size_for_policy(stacktrace_lines, @@ -434,35 +467,61 @@ class Log(object): self.accumulate_size_for_policy(self.malloc_stacktrace_lines, policy_list, buckets, sizes, False) - sizes['mmap-no-log'] = self.counters['mmap_committed'] - sizes[ - 'mmap-total-log'] - sizes['mmap-total-record'] = self.counters['mmap_committed'] - sizes['mmap-total-record-vm'] = self.counters['mmap_virtual'] - - sizes['tc-no-log'] = self.counters['tcmalloc_committed'] - sizes[ - 'tc-total-log'] - sizes['tc-total-record'] = self.counters['tcmalloc_committed'] - sizes['tc-unused'] = sizes['mmap-tcmalloc'] - self.counters[ - 'tcmalloc_committed'] + if self.log_version == DUMP_DEEP_4: + mmap_prefix = 'profiled-mmap' + malloc_prefix = 'profiled-malloc' + else: + mmap_prefix = 'mmap' + malloc_prefix = 'tcmalloc' + + sizes['mmap-no-log'] = ( + self.counters['%s_committed' % mmap_prefix] - sizes['mmap-total-log']) + sizes['mmap-total-record'] = self.counters['%s_committed' % mmap_prefix] + sizes['mmap-total-record-vm'] = self.counters['%s_virtual' % mmap_prefix] + + sizes['tc-no-log'] = ( + self.counters['%s_committed' % malloc_prefix] - sizes['tc-total-log']) + sizes['tc-total-record'] = self.counters['%s_committed' % malloc_prefix] + sizes['tc-unused'] = ( + sizes['mmap-tcmalloc'] - self.counters['%s_committed' % malloc_prefix]) sizes['tc-total'] = sizes['mmap-tcmalloc'] - for key, value in { 'total': 'total_committed', - 'filemapped': 'file_committed', - 'anonymous': 'anonymous_committed', - 'other': 'other_committed', - 'total-vm': 'total_virtual', - 'filemapped-vm': 'file_virtual', - 'anonymous-vm': 'anonymous_virtual', - 'other-vm': 'other_virtual' }.items(): + for key, value in { + 'total': 'total_committed', + 'filemapped': 'file_committed', + 'file-exec': 'file-exec_committed', + 'file-nonexec': 'file-nonexec_committed', + 'anonymous': 'anonymous_committed', + 'stack': 'stack_committed', + 'other': 'other_committed', + 'nonprofiled-absent': 'nonprofiled-absent_committed', + 'nonprofiled-anonymous': 'nonprofiled-anonymous_committed', + 'nonprofiled-file-exec': 'nonprofiled-file-exec_committed', + 'nonprofiled-file-nonexec': 'nonprofiled-file-nonexec_committed', + 'nonprofiled-stack': 'nonprofiled-stack_committed', + 'nonprofiled-other': 'nonprofiled-other_committed', + 'total-vm': 'total_virtual', + 'filemapped-vm': 'file_virtual', + 'anonymous-vm': 'anonymous_virtual', + 'other-vm': 'other_virtual' }.iteritems(): if key in sizes: sizes[key] = self.counters[value] - if 'unknown' in sizes: - sizes['unknown'] = self.counters['total_committed'] - self.counters[ - 'mmap_committed'] + if 'mustbezero' in sizes: + removed = ( + '%s_committed' % mmap_prefix, + 'nonprofiled-absent_committed', + 'nonprofiled-anonymous_committed', + 'nonprofiled-file-exec_committed', + 'nonprofiled-file-nonexec_committed', + 'nonprofiled-stack_committed', + 'nonprofiled-other_committed') + sizes['mustbezero'] = ( + self.counters['total_committed'] - + sum(self.counters[i] for i in removed)) if 'total-exclude-profiler' in sizes: - sizes['total-exclude-profiler'] = self.counters[ - 'total_committed'] - sizes['mmap-profiler'] + sizes['total-exclude-profiler'] = ( + self.counters['total_committed'] - sizes['mmap-profiler']) if 'hour' in sizes: sizes['hour'] = (self.log_time - first_log_time) / 60.0 / 60.0 if 'minute' in sizes: @@ -481,7 +540,7 @@ class Log(object): component_match = get_component(policy_list, bucket, mmap) if component_match == component_name: stacktrace_sequence = '' - for address in bucket.stacktrace[1 : min(len(bucket.stacktrace), + for address in bucket.stacktrace[0 : min(len(bucket.stacktrace), 1 + depth)]: stacktrace_sequence += address_symbol_dict[address] + ' ' if not stacktrace_sequence in sizes: diff --git a/tools/deep_memory_profiler/policy.l0.txt b/tools/deep_memory_profiler/policy.l0.txt new file mode 100644 index 0000000..9cc2a373 --- /dev/null +++ b/tools/deep_memory_profiler/policy.l0.txt @@ -0,0 +1,34 @@ +heap profile policy: POLICY_DEEP_2 +# Read policy.README for description of this file. +second optional optional +mmap-profiler mmap .*(ProfilerMalloc|MemoryRegionMap::).* +mmap-tcmalloc mmap .*(DoAllocWithArena|SbrkSysAllocator::Alloc|MmapSysAllocator::Alloc|LowLevelAlloc::Alloc|LowLevelAlloc::AllocWithArena).* +FROM_HERE_FOR_TOTAL optional optional +mustbezero optional optional +nonprofiled-absent optional optional +nonprofiled-anonymous optional optional +nonprofiled-file-exec optional optional +nonprofiled-file-nonexec optional optional +nonprofiled-stack optional optional +nonprofiled-other optional optional +no-bucket default default +mmap-v8 mmap .*v8::.* +mmap-catch-all mmap .* +tc-used-all malloc .* +tc-unused default default +UNTIL_HERE_FOR_TOTAL optional optional +total-exclude-profiler optional optional +total optional optional +anonymous optional optional +file-exec optional optional +file-nonexec optional optional +stack optional optional +other optional optional +mmap-total-log default default +mmap-no-log default default +mmap-total-record default default +other-total-log default default +tc-total-log default default +tc-no-log default default +tc-total-record default default +tc-total default default diff --git a/tools/deep_memory_profiler/policy.l1.txt b/tools/deep_memory_profiler/policy.l1.txt new file mode 100644 index 0000000..606d408 --- /dev/null +++ b/tools/deep_memory_profiler/policy.l1.txt @@ -0,0 +1,41 @@ +heap profile policy: POLICY_DEEP_2 +# Read policy.README for description of this file. +second optional optional +mmap-profiler mmap .*(ProfilerMalloc|MemoryRegionMap::).* +mmap-tcmalloc mmap .*(DoAllocWithArena|SbrkSysAllocator::Alloc|MmapSysAllocator::Alloc|LowLevelAlloc::Alloc|LowLevelAlloc::AllocWithArena).* +FROM_HERE_FOR_TOTAL optional optional +mustbezero optional optional +nonprofiled-absent optional optional +nonprofiled-anonymous optional optional +nonprofiled-file-exec optional optional +nonprofiled-file-nonexec optional optional +nonprofiled-stack optional optional +nonprofiled-other optional optional +no-bucket default default +mmap-v8-heap-newspace mmap .*v8::internal::NewSpace::SetUp.* +mmap-v8-heap-coderange mmap .*v8::internal::CodeRange::SetUp.* +mmap-v8-heap-pagedspace mmap .*v8::internal::PagedSpace::AllocateRaw.* +mmap-v8-other mmap .*v8::.* +mmap-catch-all mmap .* +tc-v8 malloc .*v8::.* +tc-skia malloc .*Sk[A-Za-z_]+::.* +tc-webkit-catch-all malloc .*(WTF::|WebCore::|WebKit::).* +tc-unknown-string malloc .*std::basic_string::_Rep::_S_create.* +tc-catch-all malloc .* +tc-unused default default +UNTIL_HERE_FOR_TOTAL optional optional +total-exclude-profiler optional optional +total optional optional +anonymous optional optional +file-exec optional optional +file-nonexec optional optional +stack optional optional +other optional optional +mmap-total-log default default +mmap-no-log default default +mmap-total-record default default +other-total-log default default +tc-total-log default default +tc-no-log default default +tc-total-record default default +tc-total default default diff --git a/tools/deep_memory_profiler/policy.l2.txt b/tools/deep_memory_profiler/policy.l2.txt new file mode 100644 index 0000000..85fa41f --- /dev/null +++ b/tools/deep_memory_profiler/policy.l2.txt @@ -0,0 +1,87 @@ +heap profile policy: POLICY_DEEP_2 +# Read policy.README for description of this file. +second optional optional +mmap-profiler mmap .*(ProfilerMalloc|MemoryRegionMap::).* +mmap-tcmalloc mmap .*(DoAllocWithArena|SbrkSysAllocator::Alloc|MmapSysAllocator::Alloc|LowLevelAlloc::Alloc|LowLevelAlloc::AllocWithArena).* +FROM_HERE_FOR_TOTAL optional optional +mustbezero optional optional +nonprofiled-absent optional optional +nonprofiled-anonymous optional optional +nonprofiled-file-exec optional optional +nonprofiled-file-nonexec optional optional +nonprofiled-stack optional optional +nonprofiled-other optional optional +no-bucket default default +mmap-v8-heap-newspace mmap .*v8::internal::NewSpace::SetUp.* +mmap-v8-heap-coderange mmap .*v8::internal::CodeRange::SetUp.* +mmap-v8-heap-pagedspace mmap .*v8::internal::PagedSpace::AllocateRaw.* +mmap-v8-other mmap .*v8::.* +mmap-catch-all mmap .* +tc-webcore-fontcache malloc .*WebCore::FontCache::getCachedFontData.* +tc-skia malloc .* Sk[A-Za-z_]+::.* +tc-renderobject malloc .*WebCore::RenderArena::allocate.* +tc-renderstyle malloc .*WebCore::RenderStyle::create.* +tc-renderstyle malloc .*WebCore::RenderStyle::clone.* +tc-webcore-sharedbuf malloc .*WebCore::SharedBuffer::create.* +tc-webcore-sharedbuf malloc .*WebCore::SharedBuffer::buffer.* +tc-webcore-sharedbuf malloc .*WebCore::SharedBuffer::append.* +tc-webcore-XHRcreate malloc .*WebCore::XMLHttpRequest::create .* +tc-webcore-XHRreceived malloc .*WebCore::XMLHttpRequest::didReceiveData.* +tc-webcore-docwriter-add malloc .*WebCore::DocumentWriter::addData.* +tc-webcore-node-and-doc malloc .*WebCore::HTML[a-zA-Z0-9_]*Element::create .* +tc-webcore-node-and-doc malloc .*WebCore::Text::create .* +tc-webcore-node-and-doc malloc .*WebCore::Comment::create .* +tc-webcore-node-and-doc malloc .*WebCore::HTMLDocument::create .* +tc-webcore-node-and-doc malloc .*WebCore::CSSStyleRule::create .* +tc-webcore-node-and-doc malloc .*WebCore::Attribute::create .* +tc-webcore-node-and-doc malloc .*WebCore::DOMWindow::create .* +tc-webcore-node-factory malloc .*WebCore::HTML[a-zA-Z0-9_]*Factory::create[a-zA-Z0-9_]*Element.* +tc-webcore-element-wrapper malloc .*WebCore::createHTML[a-zA-Z0-9_]*ElementWrapper.* +tc-webcore-stylepropertyset malloc .*WebCore::StylePropertySet::create .* +tc-webcore-style-createsheet malloc .*WebCore::StyleElement::createSheet.* +tc-webcore-cachedresource malloc .*WebCore::CachedResource::data .* +tc-webcore-cachedresource malloc .*WebCore::CachedResource::load .* +tc-webcore-script-execute malloc .*WebCore::ScriptElement::execute.* +tc-webcore-events-related malloc .*WebCore::createAttributeEventListener.* +tc-webcore-events-related malloc .*WebCore::V8LazyEventListener::create.* +tc-webcore-events-related malloc .*WebCore::V8EventListener::create.* +tc-webcore-events-related malloc .*WebCore::Event::create .* +tc-webcore-events-related malloc .*WebCore::EventListener::create .* +tc-webcore-document-write malloc .*WebCore::Document::write.* +tc-webcore-node-create-renderer malloc .*WebCore::Node::createRendererIfNeeded.* +tc-webcore-render-catch-all malloc .*WebCore::RenderLayer.* +tc-webcore-render-catch-all malloc .*WebCore::RenderBlock.* +tc-webcore-render-catch-all malloc .*WebCore::RenderWidget.* +tc-webcore-render-catch-all malloc .*WebCore::RenderView.* +tc-webcore-render-catch-all malloc .*WebCore::RenderViewImpl.* +tc-webcore-render-catch-all malloc .*WebCore::RenderStyle.* +tc-webcore-render-catch-all malloc .*WebCore::RenderText.* +tc-webcore-render-catch-all malloc .* RendererMain .* +tc-webcore-setInnerHTML-except-node malloc .*WebCore::HTMLElement::setInnerHTML.* +tc-wtf-StringImpl-user-catch-all malloc .*WTF::StringImpl::create .* +tc-wtf-StringImpl-user-catch-all malloc .*WTF::StringImpl::createUninitialized.* +tc-wtf-HashTable-user-catch-all malloc .*WTF::HashTable::allocateTable.* +#tc-wtf-fastmalloc-user-catch-all malloc .*WTF::fastMalloc .* +tc-webcore-everything-create malloc .*WebCore::[a-zA-Z0-9_]*::create .* +tc-webkit-from-v8-catch-all malloc .*(WTF::|WebCore::|WebKit::).*v8::.* +tc-webkit-catch-all malloc .*(WTF::|WebCore::|WebKit::).* +tc-v8-catch-all malloc .*v8::.* +tc-toplevel-string malloc std::basic_string::_Rep::_S_create +tc-catch-all malloc .* +tc-unused default default +UNTIL_HERE_FOR_TOTAL optional optional +total-exclude-profiler optional optional +total optional optional +anonymous optional optional +file-exec optional optional +file-nonexec optional optional +stack optional optional +other optional optional +mmap-total-log default default +mmap-no-log default default +mmap-total-record default default +other-total-log default default +tc-total-log default default +tc-no-log default default +tc-total-record default default +tc-total default default |