Changeset 21d3542


Ignore:
Timestamp:
06/02/15 16:50:48 (10 years ago)
Author:
Hal Finkel <hfinkel@…>
Branches:
master
Children:
6444e03
Parents:
192a260
git-author:
Hal Finkel <hfinkel@…> (06/02/15 16:50:48)
git-committer:
Hal Finkel <hfinkel@…> (06/02/15 16:50:48)
Message:

collect and report on mmap totals

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • memlog.cpp

    r22f928f r21d3542  
    66#include <cstdio> 
    77#include <cstring> 
     8#include <cstdint> 
    89 
    910// NOTE: This source makes very minimal use of C++11 features. It can still be 
     
    2930#ifdef __bgq__ 
    3031#include <spi/include/kernel/location.h> 
     32#include <spi/include/kernel/memory.h> 
    3133#endif 
    3234 
     
    4547static char self_path[PATH_MAX+1] = { '\0' }; 
    4648 
     49#ifdef __bgq__ 
     50int on_bgq = 0; 
     51#endif 
     52 
     53void *initial_brk = 0; 
     54 
    4755__attribute__((__constructor__)) 
    4856static void record_init() { 
     
    5462  // If we're really running on a BG/Q compute node, use the job rank instead 
    5563  // of the pid because the node name might not really be globally unique. 
    56   if (!strcmp(u.sysname, "CNK") && !strcmp(u.machine, "BGQ")) 
     64  if (!strcmp(u.sysname, "CNK") && !strcmp(u.machine, "BGQ")) { 
    5765    id = (int) Kernel_GetRank(); 
     66    on_bgq = 1; 
     67  } 
    5868#endif 
    5969 
     
    8191  const char *link_name = "/proc/self/exe"; 
    8292  readlink(link_name, self_path, PATH_MAX); 
     93 
     94  initial_brk = sbrk(0); 
    8395} 
    8496 
     
    128140  fprintf(log_file, "\t%ld.%06ld %ld %ld", usage.ru_utime.tv_sec, 
    129141          usage.ru_utime.tv_usec, usage.ru_maxrss, syscall(SYS_gettid)); 
     142 
     143  // Some other memory stats (like with maxrss, report these in KB). 
     144  size_t arena_size = ((size_t) sbrk(0)) - (size_t) initial_brk; 
     145 
     146  uint64_t mmap_size = 0; 
     147#ifdef __bgq__ 
     148  if (on_bgq) 
     149    (void) Kernel_GetMemorySize(KERNEL_MEMSIZE_MMAP, &mmap_size); 
     150#endif 
     151 
     152  fprintf(log_file, " %ld %ld", arena_size >> 10, mmap_size >> 10); 
    130153 
    131154  if (!show_backtrace) 
  • memlog_analyze

    rc83befc r21d3542  
    6464      my $state = shift(@parts); 
    6565 
    66       my ($time, $then_max_rss, $tid) = split(/\s+/, $state); 
     66      my ($time, $then_max_rss, $tid, $then_arena, $then_mmap) = 
     67        split(/\s+/, $state); 
    6768      if ($pot_max_rss < $then_max_rss) { 
    6869        $pot_max_rss = $then_max_rss; 
     
    9495# The first step is to determine the high-water mark. 
    9596my $max_rss = 0; 
     97my $arena = 0; 
     98my $mmap = 0; 
    9699foreach my $line (<MEMLOG>) { 
    97100  chomp($line); 
     
    101104  my $state = shift(@parts); 
    102105 
    103   my ($time, $then_max_rss, $tid) = split(/\s+/, $state); 
     106  my ($time, $then_max_rss, $tid, $then_arena, $then_mmap) = 
     107    split(/\s+/, $state); 
    104108  if ($max_rss < $then_max_rss) { 
    105109    $max_rss = $then_max_rss; 
     110    $arena = $then_arena; 
     111    $mmap = $then_mmap; 
    106112  } 
    107113} 
     
    131137  } 
    132138 
    133   my ($time, $then_max_rss, $tid) = split(/\s+/, $state); 
     139  my ($time, $then_max_rss, $tid, $then_arena, $then_mmap) = 
     140    split(/\s+/, $state); 
    134141  $active_alloc_time = $time; 
    135142 
     
    146153# Convert maxrss, currently in KB, to bytes. 
    147154$max_rss *= 1024; 
     155if (defined $arena) { 
     156  $arena *= 1024; 
     157} 
     158if (defined $mmap) { 
     159  $mmap *= 1024; 
     160} 
    148161 
    149162my $total_size = 0; 
     
    162175 
    163176  my ($size, $ptr) = ($op =~ /^M: (\d+) 0x(\w+)/); 
    164   my ($time, $then_max_rss, $tid) = split(/\s+/, $state); 
     177  my ($time, $then_max_rss, $tid, $then_arena, $then_mmap) = 
     178    split(/\s+/, $state); 
    165179 
    166180  $total_size += $size; 
     
    249263} 
    250264 
     265sub format_bytes_or_unk($) { 
     266  my $b = $_[0]; 
     267  return defined($b) ? format_bytes($b) : "(unknown)"; 
     268} 
     269 
    251270print DOT ("digraph \"memlog\" {\n"); 
    252271print DOT ("size=\"8,11\";\n"); 
     
    254273 
    255274my $find_type = $find_leaks ? " (leaks)" : ""; 
    256 printf DOT ("Legend [shape=box, fontsize=100, shape=oval," . 
    257             "label=\"Total: %s active$find_type at maxrss = %s after %s s\"];\n", 
     275print DOT "subgraph cluster_key {\n"; 
     276print DOT "\trank=min;\n"; 
     277print DOT "\tlabel=\"memlog\";\n"; 
     278print DOT "\tfontsize=100;\n"; 
     279print DOT "\trankdir=UR;\n"; 
     280printf DOT ("Legend [shape=box, fontsize=100, shape=plaintext," . 
     281            "label=\"Total: %s active$find_type at maxrss = %s after %s s\\narena: %s\\nmmap: %s\"];\n", 
    258282            format_bytes($total_size), format_bytes($max_rss), 
    259             $active_alloc_time); 
    260  
    261 printf TXT ("memlog: Total: %s active$find_type at maxrss = %s after %s s\n\n", 
     283            $active_alloc_time, format_bytes_or_unk($arena), 
     284            format_bytes_or_unk($mmap)); 
     285print DOT "}\n"; 
     286 
     287printf TXT ("memlog: Total: %s active$find_type at maxrss = %s after %s s\n\tarena: %s\tmmap: %s\n\n", 
    262288            format_bytes($total_size), format_bytes($max_rss), 
    263             $active_alloc_time); 
     289            $active_alloc_time, format_bytes_or_unk($arena), 
     290            format_bytes_or_unk($mmap)); 
    264291 
    265292my %cached_names; 
Note: See TracChangeset for help on using the changeset viewer.