Changeset 0edbc98 for memlog2dot
- Timestamp:
- 05/28/15 18:45:11 (9 years ago)
- Branches:
- master
- Children:
- 65ecf6c
- Parents:
- 6bfe6a1
- git-author:
- Hal Finkel <hfinkel@…> (05/28/15 18:45:11)
- git-committer:
- Hal Finkel <hfinkel@…> (05/28/15 18:45:11)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
memlog2dot
r6bfe6a1 r0edbc98 15 15 open(MEMLOG, $memlog_fn) || die "Can't open $memlog_fn: $!"; 16 16 17 # The first step is to determine the high-water mark. 18 my $max_rss = 0; 19 foreach my $line (<MEMLOG>) { 20 chomp($line); 21 my @parts = split(/\t/, $line); 22 23 my $op = shift(@parts); 24 my $state = shift(@parts); 25 26 my ($time, $then_max_rss, $tid) = split(/\s+/, $state); 27 if ($max_rss < $then_max_rss) { 28 $max_rss = $then_max_rss; 29 } 30 } 31 32 seek(MEMLOG, 0, 0); 33 34 # Scan the log for malloc/free pairings. We're interested only in active 35 # allocations at the time when the rss reaches the final maxrss. 36 my $max_rss_time = 0; 37 my %malloc_lines; 38 foreach my $line (<MEMLOG>) { 39 chomp($line); 40 my @parts = split(/\t/, $line); 41 42 my $op = shift(@parts); 43 my $state = shift(@parts); 44 45 if ($op =~ /^M:/) { 46 my ($size, $ptr) = ($op =~ /^M: (\d+) 0x(\w+)/); 47 $malloc_lines{$ptr} = $line; 48 } elsif ($op =~ /^F:/) { 49 my ($ptr) = ($op =~ /^F: 0x(\w+)/); 50 delete $malloc_lines{$ptr}; 51 } else { 52 next; 53 } 54 55 # If we've reached the max rss, we've seen all we need to see. 56 my ($time, $then_max_rss, $tid) = split(/\s+/, $state); 57 $max_rss_time = $time; 58 if ($then_max_rss == $max_rss) { 59 last; 60 } 61 } 62 63 close(MEMLOG); 64 65 # Convert maxrss, currently in KB, to bytes. 66 $max_rss *= 1024; 67 17 68 my $total_size = 0; 18 69 my %roots; 19 70 my %all_nodes; 20 foreach my $line (<MEMLOG>) { 21 chomp($line); 71 foreach my $line (values %malloc_lines) { 22 72 my @parts = split(/\t/, $line); 23 73 … … 31 81 32 82 my ($size, $ptr) = ($op =~ /^M: (\d+) 0x(\w+)/); 33 my ($time, $ maxrss, $tid) = split(/\s+/, $state);83 my ($time, $then_max_rss, $tid) = split(/\s+/, $state); 34 84 35 85 $total_size += $size; … … 88 138 } 89 139 90 close(MEMLOG);91 92 140 my $dot_fn = "$out_dir/" . basename($memlog_fn) . ".dot"; 93 141 my $ps_fn = "$out_dir/" . basename($memlog_fn) . ".ps"; … … 109 157 } 110 158 111 printf DOT ("digraph \"memlog %s\" {\n", format_bytes($total_size)); 159 printf DOT ("digraph \"memlog %s (maxrss = %s after %s s)\" {\n", 160 format_bytes($total_size), format_bytes($max_rss), $max_rss_time); 112 161 print DOT ("size=\"8,11\";\n"); 113 162 print DOT ("node [width=0.375,height=0.25];\n");
Note: See TracChangeset
for help on using the changeset viewer.