Revision: 5102
Author: [email protected]
Date: Tue Jul 20 03:59:00 2010
Log: Output time spent in code flushing in GC NVP trace.

Add support for flushcode scope and cumulative stats into gc-nvp-trace-processor.

Review URL: http://codereview.chromium.org/3054003
http://code.google.com/p/v8/source/detail?r=5102

Modified:
 /branches/bleeding_edge/src/heap.cc
 /branches/bleeding_edge/src/heap.h
 /branches/bleeding_edge/tools/gc-nvp-trace-processor.py

=======================================
--- /branches/bleeding_edge/src/heap.cc Thu Jul 15 06:21:50 2010
+++ /branches/bleeding_edge/src/heap.cc Tue Jul 20 03:59:00 2010
@@ -638,6 +638,7 @@
   if (collector == MARK_COMPACTOR) {
     if (FLAG_flush_code) {
       // Flush all potentially unused code.
+      GCTracer::Scope gc_scope(tracer, GCTracer::Scope::MC_FLUSH_CODE);
       FlushCode();
     }

@@ -4841,6 +4842,7 @@
     PrintF("mark=%d ", static_cast<int>(scopes_[Scope::MC_MARK]));
     PrintF("sweep=%d ", static_cast<int>(scopes_[Scope::MC_SWEEP]));
     PrintF("compact=%d ", static_cast<int>(scopes_[Scope::MC_COMPACT]));
+ PrintF("flushcode=%d ", static_cast<int>(scopes_[Scope::MC_FLUSH_CODE]));

     PrintF("total_size_before=%d ", start_size_);
     PrintF("total_size_after=%d ", Heap::SizeOfObjects());
=======================================
--- /branches/bleeding_edge/src/heap.h  Tue Jul 13 06:06:33 2010
+++ /branches/bleeding_edge/src/heap.h  Tue Jul 20 03:59:00 2010
@@ -1722,6 +1722,7 @@
       MC_MARK,
       MC_SWEEP,
       MC_COMPACT,
+      MC_FLUSH_CODE,
       kNumberOfScopes
     };

=======================================
--- /branches/bleeding_edge/tools/gc-nvp-trace-processor.py Tue May 18 09:50:17 2010 +++ /branches/bleeding_edge/tools/gc-nvp-trace-processor.py Tue Jul 20 03:59:00 2010
@@ -47,8 +47,12 @@

 def split_nvp(s):
   t = {}
-  for m in re.finditer(r"(\w+)=(-?\d+)", s):
-    t[m.group(1)] = int(m.group(2))
+  for (name, value) in re.findall(r"(\w+)=([-\w]+)", s):
+    try:
+      t[name] = int(value)
+    except ValueError:
+      t[name] = value
+
   return t

 def parse_gc_trace(input):
@@ -211,6 +215,9 @@
 def reclaimed_bytes(row):
   return row['total_size_before'] - row['total_size_after']

+def other_scope(r):
+ return r['pause'] - r['mark'] - r['sweep'] - r['compact'] - r['flushcode']
+
 plots = [
   [
     Set('style fill solid 0.5 noborder'),
@@ -219,9 +226,8 @@
     Plot(Item('Marking', 'mark', lc = 'purple'),
          Item('Sweep', 'sweep', lc = 'blue'),
          Item('Compaction', 'compact', lc = 'red'),
-         Item('Other',
-              lambda r: r['pause'] - r['mark'] - r['sweep'] - r['compact'],
-              lc = 'grey'))
+         Item('Flush Code', 'flushcode', lc = 'yellow'),
+         Item('Other', other_scope, lc = 'grey'))
   ],
   [
     Set('style histogram rowstacked'),
@@ -256,19 +262,48 @@
   ],
 ]

+def calc_total(trace, field):
+  return reduce(lambda t,r: t + r[field], trace, 0)
+
+def calc_max(trace, field):
+  return reduce(lambda t,r: max(t, r[field]), trace, 0)
+
 def process_trace(filename):
   trace = parse_gc_trace(filename)
-  total_gc = reduce(lambda t,r: t + r['pause'], trace, 0)
-  max_gc = reduce(lambda t,r: max(t, r['pause']), trace, 0)
+  total_gc = calc_total(trace, 'pause')
+  max_gc = calc_max(trace, 'pause')
   avg_gc = total_gc / len(trace)

+  total_sweep = calc_total(trace, 'sweep')
+  max_sweep = calc_max(trace, 'sweep')
+
+  total_mark = calc_total(trace, 'mark')
+  max_mark = calc_max(trace, 'mark')
+
+  scavenges = filter(lambda r: r['gc'] == 's', trace)
+  total_scavenge = calc_total(scavenges, 'pause')
+  max_scavenge = calc_max(scavenges, 'pause')
+  avg_scavenge = total_scavenge / len(scavenges)
+
   charts = plot_all(plots, trace, filename)

   with open(filename + '.html', 'w') as out:
     out.write('<html><body>')
+    out.write('<table><tr><td>')
     out.write('Total in GC: <b>%d</b><br/>' % total_gc)
     out.write('Max in GC: <b>%d</b><br/>' % max_gc)
     out.write('Avg in GC: <b>%d</b><br/>' % avg_gc)
+    out.write('</td><td>')
+    out.write('Total in Scavenge: <b>%d</b><br/>' % total_scavenge)
+    out.write('Max in Scavenge: <b>%d</b><br/>' % max_scavenge)
+    out.write('Avg in Scavenge: <b>%d</b><br/>' % avg_scavenge)
+    out.write('</td><td>')
+    out.write('Total in Sweep: <b>%d</b><br/>' % total_sweep)
+    out.write('Max in Sweep: <b>%d</b><br/>' % max_sweep)
+    out.write('</td><td>')
+    out.write('Total in Mark: <b>%d</b><br/>' % total_mark)
+    out.write('Max in Mark: <b>%d</b><br/>' % max_mark)
+    out.write('</td></tr></table>')
     for chart in charts:
       out.write('<img src="%s">' % chart)
       out.write('</body></html>')

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to