[pypy-svn] r59828 - pypy/build/benchmem

xoraxax at codespeak.net xoraxax at codespeak.net
Sat Nov 8 19:31:15 CET 2008


Author: xoraxax
Date: Sat Nov  8 19:31:14 2008
New Revision: 59828

Modified:
   pypy/build/benchmem/report_graphic.py
   pypy/build/benchmem/runbench.py
Log:
Revert back to full snapshots again to have an easier way to fix the reporting code to report different data. Now the graphs look saner and we can see that the import triggers a 3 MB heap allocation.

Modified: pypy/build/benchmem/report_graphic.py
==============================================================================
--- pypy/build/benchmem/report_graphic.py	(original)
+++ pypy/build/benchmem/report_graphic.py	Sat Nov  8 19:31:14 2008
@@ -97,12 +97,12 @@
                 else:
                     x = [(val - min_ts)/d_ts*100 for val in timestamps]
                 if base_snapshots:
-                    basesize = base_snapshots[result.executable].private
+                    basesize = base_snapshots[result.executable].heap_and_data(result)
                 else:
                     basesize = 0
                 # XXX we also measure the working set of the data segment or
                 # third party libraries here
-                y = [snapshot.private - basesize
+                y = [snapshot.heap_and_data(result) - basesize
                      for snapshot in result.snapshots]
                 plots.append(pylab.plot(x, y))
             pylab.title(name)
@@ -110,7 +110,7 @@
             pylab.legend(plots, [result.executable_short for result in results])
             xlabel = ["wall clock time (%)", "wall clock time (s)"][SHOW_TS]
             pylab.xlabel(xlabel)
-            ylabel = ["", "incremental "][bool(basesize)] + "private memory consumption (kB)"
+            ylabel = ["", "incremental "][bool(basesize)] + "heap and dirty static data consumption (kB)"
             pylab.ylabel(ylabel)
             if self.basepath is not None:
                 pylab.savefig(self.basepath + 'appprofiles_%s%s' % (name, EXT))

Modified: pypy/build/benchmem/runbench.py
==============================================================================
--- pypy/build/benchmem/runbench.py	(original)
+++ pypy/build/benchmem/runbench.py	Sat Nov  8 19:31:14 2008
@@ -210,7 +210,7 @@
             self.run_once(name)
             
     def run_once(self, name):
-        benchpyfile, runner_file = self.makebench(name)
+        runner_file = self.makebench(name)
         #self.log("created", benchpyfile)
         cmd = "%s -u "% (self.executable, )
         self.log("running %s(%s)" %(name, self.options.numiter))
@@ -222,10 +222,12 @@
         # first compile the modules by importing a module that imports
         os.system(cmd + str(runner_file))
 
-        stdout, stdin = os.popen2(cmd + str(benchpyfile))
+        stdout, stdin = os.popen2(cmd + str(runner_file) + " run")
         pid = int(stdin.readline())
         self.write_benchheader(name, self.options.numiter)
         rec = smaps.SmapsRecorder(pid, self.logstream)
+        self.write_internal_header({"TS": str(time.time())})
+        rec.snapshot()
         stdout.write("!")
         stdout.flush()
         self.interact_with_child(rec, stdout, stdin)
@@ -236,32 +238,35 @@
         runner_file.write(py.code.Source("""
             import sys
             sys.path.append(%r)
-            import %s
+            from %s import init
+            init()
         """ % (str(self.tmpdir), self.benchpath.basename[:-3])))
-        source = py.code.Source(self.getbenchsource(), """
-            import gc
+        source = py.code.Source("""
+            import sys, gc, os
             def write(c):
                 sys.stdout.write(c)
                 sys.stdout.flush()
 
-            if __name__ == "__main__":
-                import os, sys, gc
-                if len(sys.argv) > 1 and sys.argv[1] == '--importonly':
-                    raise SystemExit
+            if len(sys.argv) > 1 and sys.argv[1] == 'run':
                 pid = os.getpid()
                 write(str(pid) + "\\n")
                 sys.stdin.read(1)
+                """, self.getbenchsource(), """
+
+            def init():
                 %s %s
                 sys.stdin.close()
+
         """ %(name, arglist))
         p = self.tmpdir.join(self.benchpath.basename)
         p.write(source)
-        return p, runner_file
+        return runner_file
     
     def interact_with_child(self, rec, stdin, stdout):
         while not stdin.closed:
             try:
-                rec.simple_snapshot()
+                self.write_internal_header({"TS": str(time.time())})
+                rec.snapshot()
             except py.error.ENOENT:
                 break
         rec.stream.flush()
@@ -432,23 +437,10 @@
 
     def __init__(self, snapshots, *args, **kwargs):
         CommonResult.__init__(self, snapshots, *args, **kwargs)
-        self.min = min(ss.private for ss in snapshots)
-        self.max = max(ss.private for ss in snapshots)
+        self.min = min(ss.heap_and_data(self) for ss in snapshots)
+        self.max = max(ss.heap_and_data(self) for ss in snapshots)
         # XXX this way we are not integrating over time so we have skew again
-        self.avg = sum(ss.private for ss in snapshots) / float(len(snapshots))
-
-    @classmethod
-    def parse(cls, lnstream, kw):
-        snapshots = []
-        for lineno, line in lnstream:
-            line = line.rstrip()
-            if line == BenchRunner.SEPBENCH:
-                break
-            else:
-                a, b = line.split()
-                snapshots.append(SimpleSnapshot(int(b), float(a)))
-                continue
-        return cls(snapshots, **kw)
+        self.avg = sum(ss.heap_and_data(self) for ss in snapshots) / float(len(snapshots))
 
 
 class BasesizeResult(Result):
@@ -549,10 +541,15 @@
         assert mappings
         self.header = headerkw
         Mappings.__init__(self, mappings)
+        if "TS" in headerkw:
+            self.timestamp = float(headerkw["TS"])
 
     def heap_private(self):
         return self.filter(group=self.HEAP).private
 
+    def heap_and_data(self, result):
+        return self.filter(group=self.HEAP).private_dirty + self.filter(group=result.executable, kind=self.DATA).private_dirty
+
 #
 # ==============================================================================
 # Option Handling



More information about the Pypy-commit mailing list