diff options
Diffstat (limited to 'tools/memory_watcher')
-rw-r--r-- | tools/memory_watcher/scripts/memprof.pl | 32 | ||||
-rw-r--r-- | tools/memory_watcher/scripts/memtrace.pl | 32 | ||||
-rw-r--r-- | tools/memory_watcher/scripts/summary.pl | 62 |
3 files changed, 84 insertions, 42 deletions
diff --git a/tools/memory_watcher/scripts/memprof.pl b/tools/memory_watcher/scripts/memprof.pl index 95fdd4c..571336f 100644 --- a/tools/memory_watcher/scripts/memprof.pl +++ b/tools/memory_watcher/scripts/memprof.pl @@ -13,22 +13,20 @@ # # Sample output: # -# 54061617 100.00% AllocationStack::AllocationStack -# 41975368 77.64% malloc -# 11886592 21.99% VirtualAlloc -# 7168000 13.26% v8::internal::OS::Allocate -# 7168000 13.26% v8::internal::MemoryAllocator::AllocateRawMemory -# 5976184 11.05% WebCore::V8Bridge::evaluate -# 5767168 10.67% v8::internal::MemoryAllocator::AllocatePages -# 5451776 10.08% WebCore::V8Proxy::initContextIfNeeded +# 54,061,617 100.00% AllocationStack::AllocationStack +# 41,975,368 77.64% malloc +# 11,886,592 21.99% VirtualAlloc +# 7,168,000 13.26% v8::internal::OS::Allocate +# 7,168,000 13.26% v8::internal::MemoryAllocator::AllocateRawMemory +# 5,976,184 11.05% WebCore::V8Bridge::evaluate +# 5,767,168 10.67% v8::internal::MemoryAllocator::AllocatePages +# 5,451,776 10.08% WebCore::V8Proxy::initContextIfNeeded # .... # # # # ******** -# Note: The output is not currently sorted. To make it more legible, -# you will want to sort numerically by the first field: -# $ ./memprof.pl memwatcher.log3620.txt | sort -n -r +# Note: The output is currently sorted by decreasing size. # ******** # @@ -90,15 +88,21 @@ sub process_raw($$) { # now dump our hash table my $sum = 0; - my @keys = keys(%leaks); + my @keys = sort { $leaks{$b} <=> $leaks{$a} }keys %leaks; for ($i=0; $i<@keys; $i++) { my $key = @keys[$i]; - printf "%8d\t%3.2f%%\t%s\n", $leaks{$key}, (100* $leaks{$key} / $total_bytes), $key; + printf "%11s\t%3.2f%%\t%s\n", comma_print($leaks{$key}), (100* $leaks{$key} / $total_bytes), $key; $sum += $leaks{$key}; } - print("TOTAL: $sum\n"); + printf("TOTAL: %s\n", comma_print($sum)); } +# Insert commas into an integer after each three digits for printing. +sub comma_print { + my $num = "$_[0]"; + $num =~ s/(\d{1,3}?)(?=(\d{3})+$)/$1,/g; + return $num; +} # ----- Main ------------------------------------------------ diff --git a/tools/memory_watcher/scripts/memtrace.pl b/tools/memory_watcher/scripts/memtrace.pl index 3c014d0..0d36efa 100644 --- a/tools/memory_watcher/scripts/memtrace.pl +++ b/tools/memory_watcher/scripts/memtrace.pl @@ -15,20 +15,15 @@ # # Sample output: # -# 41975368 77.64% f:\sp\vctools\crt_bld\self_x86\crt\src\malloc.c (163): malloc -# 2097152 3.88% c:\src\chrome1\src\webkit\pending\frameloader.cpp (3300): WebCore::FrameLoader::committedLoad -# 1572864 2.91% c:\src\chrome1\src\webkit\port\bridge\v8bridge.cpp (214): WebCore::V8Bridge::evaluate -# 1572864 2.91% c:\src\chrome1\src\webkit\glue\webframeloaderclient_impl.cc (1071): WebFrameLoaderClient::committedLoad -# 1572864 2.91% c:\src\chrome1\src\v8\src\ast.h (1181): v8::internal::Visitor::Visit +# 41,975,368 77.64% f:\sp\vctools\crt_bld\self_x86\crt\src\malloc.c (163): malloc +# 2,097,152 3.88% c:\src\chrome1\src\webkit\pending\frameloader.cpp (3300): WebCore::FrameLoader::committedLoad +# 1,572,864 2.91% c:\src\chrome1\src\webkit\port\bridge\v8bridge.cpp (214): WebCore::V8Bridge::evaluate +# 1,572,864 2.91% c:\src\chrome1\src\webkit\glue\webframeloaderclient_impl.cc (1071): WebFrameLoaderClient::committedLoad +# 1,572,864 2.91% c:\src\chrome1\src\v8\src\ast.h (1181): v8::internal::Visitor::Visit # # # -# ******** -# Note: The output is not currently sorted. To make it more legible, -# you will want to sort numerically by the first field: -# $ ./memtrace.pl memwatcher.log3620.txt | sort -n -r -# ******** -# + sub process_raw($) { my $file = shift; @@ -81,7 +76,7 @@ sub process_raw($) { elsif ($line =~ m/Untracking untracked/) { next; } - elsif ($line =~ m/[ ]*(c:\\trunk\\[a-zA-Z_\\0-9\.]*) /) { + elsif ($line =~ m/[ ]*([a-z]:\\[a-z]*\\[a-zA-Z_\\0-9\.]*) /) { my $filename = $1; if ($filename =~ m/memory_watcher/) { next; @@ -123,15 +118,22 @@ sub process_raw($) { # now dump our hash table my $sum = 0; - my @keys = keys(%leaks); + my @keys = sort { $leaks{$b} <=> $leaks{$a} }keys %leaks; for ($i=0; $i<@keys; $i++) { my $key = @keys[$i]; - printf "%8d\t%3.2f%%\t%s\n", $leaks{$key}, (100* $leaks{$key} / $total_bytes), $key; + if (0 == $total_bytes) { $total_bytes = 1; } + printf "%11s\t%3.2f%%\t%s\n", comma_print($leaks{$key}), (100* $leaks{$key} / $total_bytes), $key; $sum += $leaks{$key}; } - print("TOTAL: $sum\n"); + printf("TOTAL: %s\n", comma_print($sum)); } +# Insert commas into an integer after each three digits for printing. +sub comma_print { + my $num = "$_[0]"; + $num =~ s/(\d{1,3}?)(?=(\d{3})+$)/$1,/g; + return $num; +} # ----- Main ------------------------------------------------ diff --git a/tools/memory_watcher/scripts/summary.pl b/tools/memory_watcher/scripts/summary.pl index 005fabe..257e5a3 100644 --- a/tools/memory_watcher/scripts/summary.pl +++ b/tools/memory_watcher/scripts/summary.pl @@ -20,16 +20,29 @@ sub process_stdin() { chomp($line); my $bytes, $loc; ($bytes, $loc) = ($line =~ m/[ \t]*([0-9]*)[ \t]*[0-9\.%]*[ \t]*(.*)/); + chomp($loc); + while(<STDIN>) { + my $cont = $_; + chomp($cont); + last if $cont =~ m/=====/; + $loc .= "\n" . $cont; + } my $location_blame = ""; # print "Found: $bytes, $loc\n"; - - $total_bytes += $bytes; - - if ($loc =~ m/v8/) { + + if ($loc =~ m/v8::internal::Snapshot::Deserialize/) { + $location_blame = "v8 Snapshot Deserialize"; + } elsif ($loc =~ m/v8::internal::OldSpace::SlowAllocateRaw/) { + $location_blame = "v8 OldSpace"; + } elsif ($loc =~ m/v8/) { $location_blame = "v8"; } elsif ($loc =~ m/sqlite/) { $location_blame = "sqlite"; + } elsif ($loc =~ m/ TransportDIB::Map/) { + $location_blame = "Shared Memory Backing Store"; + } elsif ($loc =~ m/imagedecoder/) { + $location_blame = "img decoder"; } elsif ($loc =~ m/SkBitmap/) { $location_blame = "skia"; } elsif ($loc =~ m/disk_cache/) { @@ -58,8 +71,6 @@ sub process_stdin() { $location_blame = "plugin"; } elsif ($loc =~ m/hunspell/) { $location_blame = "hunspell"; - } elsif ($loc =~ m/decoder/) { - $location_blame = "img decoder"; } elsif ($loc =~ m/TextCodec/) { $location_blame = "fonts"; } elsif ($loc =~ m/glyph/) { @@ -70,6 +81,10 @@ sub process_stdin() { $location_blame = "webkit css"; } elsif ($loc =~ m/Arena/) { $location_blame = "webkit arenas"; + } elsif ($loc =~ m/WebCore::.*ResourceLoader::addData/) { + $location_blame = "WebCore *ResourceLoader addData"; + } elsif ($loc =~ m/OnUpdateVisitedLinks/) { + $location_blame = "OnUpdateVisitedLinks"; } elsif ($loc =~ m/IPC/) { $location_blame = "ipc"; } elsif ($loc =~ m/trunk\\chrome\\browser/) { @@ -86,31 +101,52 @@ sub process_stdin() { $location_blame = "webkit javascriptcore"; } elsif ($loc =~ m/webkit/) { $location_blame = "webkit other"; -# print "$location_blame: ($bytes) $loc\n"; + } elsif ($loc =~ m/safe_browsing/) { + $location_blame = "safe_browsing"; + } elsif ($loc =~ m/VisitedLinkMaster/) { + $location_blame = "VisitedLinkMaster"; + } elsif ($loc =~ m/NewDOMUI/) { + $location_blame = "NewDOMUI"; + } elsif ($loc =~ m/RegistryControlledDomainService/) { + $location_blame = "RegistryControlledDomainService"; + } elsif ($loc =~ m/URLRequestChromeJob::DataAvailable/) { + $location_blame = "URLRequestChromeJob DataAvailable"; + } elsif ($loc =~ m/history_publisher/) { + $location_blame = "history publisher"; } else { $location_blame = "unknown"; # print "$location_blame: ($bytes) $loc\n"; } - # surface large outliers - if ($bytes > 1000000 && $location_blame eq "unknown") { - $location_blame = $loc; + # Surface large outliers in an "interesting" group. + # When questioned about a specific group listed above, we + # can just enter its name here, and get details. + # TODO(jar): Add this as a pair of shell arguments. + if ($bytes > 10000000 && $location_blame eq "unknown") { + $location_blame = "\n" . $loc; } + $total_bytes += $bytes; $leaks{$location_blame} += $bytes; } # now dump our hash table my $sum = 0; - my @keys = keys(%leaks); + my @keys = sort { $leaks{$b} <=> $leaks{$a} }keys %leaks; for ($i=0; $i<@keys; $i++) { my $key = @keys[$i]; - printf "%8d\t%3.2f%%\t%s\n", $leaks{$key}, (100* $leaks{$key} / $total_bytes), $key; + printf "%11s\t%3.2f%%\t%s\n", comma_print($leaks{$key}), (100* $leaks{$key} / $total_bytes), $key; $sum += $leaks{$key}; } - print("TOTAL: $sum\n"); + printf("TOTAL: %s\n", comma_print($sum)); } +# Insert commas into an integer after each three digits for printing. +sub comma_print { + my $num = "$_[0]"; + $num =~ s/(\d{1,3}?)(?=(\d{3})+$)/$1,/g; + return $num; +} # ----- Main ------------------------------------------------ |