Reviewers: Erik Corry,

Description:
Add GC throughput metrics to gc-nvp-trace-processor.

Please review this at http://codereview.chromium.org/6220001/

SVN Base: https://v8.googlecode.com/svn/branches/experimental/gc

Affected files:
  M tools/gc-nvp-trace-processor.py


Index: tools/gc-nvp-trace-processor.py
diff --git a/tools/gc-nvp-trace-processor.py b/tools/gc-nvp-trace-processor.py index 2c173ab56ee456d4f27cd08bf7810eeef4501468..f1596d2b2b7406b698e6700e555c8c05d8795730 100755
--- a/tools/gc-nvp-trace-processor.py
+++ b/tools/gc-nvp-trace-processor.py
@@ -265,7 +265,7 @@ def freduce(f, field, trace, init):
   return reduce(lambda t,r: f(t, r[field]), trace, init)

 def calc_total(trace, field):
-  return freduce(lambda t,v: t + v, field, trace, 0)
+  return freduce(lambda t,v: t + long(v), field, trace, long(0))

 def calc_max(trace, field):
   return freduce(lambda t,r: max(t, r), field, trace, 0)
@@ -280,6 +280,8 @@ def process_trace(filename):
   marksweeps = filter(lambda r: r['gc'] == 'ms', trace)
   markcompacts = filter(lambda r: r['gc'] == 'mc', trace)
   scavenges = filter(lambda r: r['gc'] == 's', trace)
+  globalgcs = filter(lambda r: r['gc'] != 's', trace)
+

   charts = plot_all(plots, trace, filename)

@@ -292,7 +294,7 @@ def process_trace(filename):
     else:
       avg = 0
     if n > 1:
- dev = math.sqrt(freduce(lambda t,r: (r - avg) ** 2, field, trace, 0) / + dev = math.sqrt(freduce(lambda t,r: t + (r - avg) ** 2, field, trace, 0) /
                       (n - 1))
     else:
       dev = 0
@@ -301,6 +303,29 @@ def process_trace(filename):
               '<td>%d</td><td>%d [dev %f]</td></tr>' %
               (prefix, n, total, max, avg, dev))

+  def HumanReadable(size):
+    suffixes = ['B', 'KB', 'MB', 'GB']
+    power = 1
+    for i in range(len(suffixes)):
+      if size < power*1024:
+        return "%.1f" % (float(size) / power) + " " + suffixes[i]
+      power *= 1024
+
+  def throughput(name, trace):
+    total_live_after = calc_total(trace, 'total_size_after')
+    total_live_before = calc_total(trace, 'total_size_before')
+    total_gc = calc_total(trace, 'pause')
+    out.write('GC %s Throughput (after): %s / %s ms = %s/ms<br/>' %
+              (name,
+               HumanReadable(total_live_after),
+               total_gc,
+               HumanReadable(total_live_after / total_gc)))
+    out.write('GC %s Throughput (before): %s / %s ms = %s/ms<br/>' %
+              (name,
+               HumanReadable(total_live_before),
+               total_gc,
+               HumanReadable(total_live_before / total_gc)))
+

   with open(filename + '.html', 'w') as out:
     out.write('<html><body>')
@@ -315,6 +340,11 @@ def process_trace(filename):
     stats(out, 'Sweep', filter(lambda r: r['sweep'] != 0, trace), 'sweep')
stats(out, 'Compact', filter(lambda r: r['compact'] != 0, trace), 'compact')
     out.write('</table>')
+    throughput('TOTAL', trace)
+    throughput('MS', marksweeps)
+    throughput('MC', markcompacts)
+    throughput('OLDSPACE', globalgcs)
+    out.write('<br/>')
     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