[pypy-svn] r69448 - in pypy/branch/compress-virtuals-resumedata/pypy/jit/metainterp: . test
cfbolz at codespeak.net
cfbolz at codespeak.net
Thu Nov 19 16:07:35 CET 2009
Author: cfbolz
Date: Thu Nov 19 16:07:34 2009
New Revision: 69448
Modified:
pypy/branch/compress-virtuals-resumedata/pypy/jit/metainterp/jitprof.py
pypy/branch/compress-virtuals-resumedata/pypy/jit/metainterp/optimizeopt.py
pypy/branch/compress-virtuals-resumedata/pypy/jit/metainterp/resume.py
pypy/branch/compress-virtuals-resumedata/pypy/jit/metainterp/test/test_jitprof.py
Log:
(pedronis, cfbolz): add counting of how much reusing of virtuals we do
Modified: pypy/branch/compress-virtuals-resumedata/pypy/jit/metainterp/jitprof.py
==============================================================================
--- pypy/branch/compress-virtuals-resumedata/pypy/jit/metainterp/jitprof.py (original)
+++ pypy/branch/compress-virtuals-resumedata/pypy/jit/metainterp/jitprof.py Thu Nov 19 16:07:34 2009
@@ -20,6 +20,9 @@
OPT_FORCINGS
ABORT_TOO_LONG
ABORT_BRIDGE
+NVIRTUALS
+NVHOLES
+NVREUSED
"""
def _setup():
@@ -175,6 +178,9 @@
self._print_intline("forcings", cnt[OPT_FORCINGS])
self._print_intline("trace too long", cnt[ABORT_TOO_LONG])
self._print_intline("bridge abort", cnt[ABORT_BRIDGE])
+ self._print_intline("nvirtuals", cnt[NVIRTUALS])
+ self._print_intline("nvholes", cnt[NVHOLES])
+ self._print_intline("nvreused", cnt[NVREUSED])
def _print_line_time(self, string, i, tim):
final = "%s:%s\t%d\t%f\n" % (string, " " * max(0, 13-len(string)), i, tim)
Modified: pypy/branch/compress-virtuals-resumedata/pypy/jit/metainterp/optimizeopt.py
==============================================================================
--- pypy/branch/compress-virtuals-resumedata/pypy/jit/metainterp/optimizeopt.py (original)
+++ pypy/branch/compress-virtuals-resumedata/pypy/jit/metainterp/optimizeopt.py Thu Nov 19 16:07:34 2009
@@ -2,7 +2,7 @@
ConstFloat
from pypy.jit.metainterp.history import Const, ConstInt, ConstPtr, ConstObj, REF
from pypy.jit.metainterp.resoperation import rop, ResOperation
-from pypy.jit.metainterp.jitprof import OPT_OPS, OPT_GUARDS, OPT_FORCINGS
+from pypy.jit.metainterp import jitprof
from pypy.jit.metainterp.executor import execute_nonspec
from pypy.jit.metainterp.specnode import SpecNode, NotSpecNode, ConstantSpecNode
from pypy.jit.metainterp.specnode import AbstractVirtualStructSpecNode
@@ -388,7 +388,7 @@
self.bool_boxes = {}
def forget_numberings(self, virtualbox):
- self.metainterp_sd.profiler.count(OPT_FORCINGS)
+ self.metainterp_sd.profiler.count(jitprof.OPT_FORCINGS)
self.resumedata_memo.forget_numberings(virtualbox)
def getinterned(self, box):
@@ -514,6 +514,8 @@
else:
self.optimize_default(op)
self.loop.operations = self.newoperations
+ # accumulate counters
+ self.resumedata_memo.update_counters(self.metainterp_sd.profiler)
def emit_operation(self, op, must_clone=True):
self.heap_op_optimizer.emitting_operation(op)
@@ -526,9 +528,9 @@
op = op.clone()
must_clone = False
op.args[i] = box
- self.metainterp_sd.profiler.count(OPT_OPS)
+ self.metainterp_sd.profiler.count(jitprof.OPT_OPS)
if op.is_guard():
- self.metainterp_sd.profiler.count(OPT_GUARDS)
+ self.metainterp_sd.profiler.count(jitprof.OPT_GUARDS)
self.store_final_boxes_in_guard(op)
elif op.can_raise():
self.exception_might_have_happened = True
Modified: pypy/branch/compress-virtuals-resumedata/pypy/jit/metainterp/resume.py
==============================================================================
--- pypy/branch/compress-virtuals-resumedata/pypy/jit/metainterp/resume.py (original)
+++ pypy/branch/compress-virtuals-resumedata/pypy/jit/metainterp/resume.py Thu Nov 19 16:07:34 2009
@@ -1,6 +1,7 @@
import sys, os
from pypy.jit.metainterp.history import Box, Const, ConstInt, INT, REF
from pypy.jit.metainterp.resoperation import rop
+from pypy.jit.metainterp import jitprof
from pypy.rpython.lltypesystem import rffi
from pypy.rlib import rarithmetic
from pypy.rlib.objectmodel import we_are_translated
@@ -112,6 +113,10 @@
self.numberings = {}
self.cached_boxes = {}
self.cached_virtuals = {}
+
+ self.nvirtuals = 0
+ self.nvholes = 0
+ self.nvreused = 0
def getconst(self, const):
if const.type == INT:
@@ -217,6 +222,10 @@
self.cached_boxes.clear()
self.cached_virtuals.clear()
+ def update_counters(self, profiler):
+ profiler.count(jitprof.NVIRTUALS, self.nvirtuals)
+ profiler.count(jitprof.NVHOLES, self.nvholes)
+ profiler.count(jitprof.NVREUSED, self.nvreused)
_frame_info_placeholder = (None, 0, 0)
@@ -315,12 +324,18 @@
if vfieldboxes:
length = num_env_virtuals + memo.num_cached_virtuals()
virtuals = storage.rd_virtuals = [None] * length
+ memo.nvirtuals += length
+ memo.nvholes += length - len(vfieldboxes)
for virtualbox, fieldboxes in vfieldboxes.iteritems():
num, _ = untag(self.liveboxes[virtualbox])
value = values[virtualbox]
fieldnums = [self._gettagged(box)
for box in fieldboxes]
vinfo = value.make_virtual_info(self, fieldnums)
+ # if a new vinfo instance is made, we get the fieldnums list we
+ # pass in as an attribute. hackish.
+ if vinfo.fieldnums is not fieldnums:
+ memo.nvreused += 1
virtuals[num] = vinfo
def _gettagged(self, box):
Modified: pypy/branch/compress-virtuals-resumedata/pypy/jit/metainterp/test/test_jitprof.py
==============================================================================
--- pypy/branch/compress-virtuals-resumedata/pypy/jit/metainterp/test/test_jitprof.py (original)
+++ pypy/branch/compress-virtuals-resumedata/pypy/jit/metainterp/test/test_jitprof.py Thu Nov 19 16:07:34 2009
@@ -63,7 +63,8 @@
]
assert profiler.events == expected
assert profiler.times == [2, 1, 1, 1]
- assert profiler.counters == [1, 1, 1, 1, 4, 3, 1, 1, 7, 1, 0, 0, 0]
+ assert profiler.counters == [1, 1, 1, 1, 4, 3, 1, 1, 7, 1, 0, 0, 0,
+ 0, 0, 0]
def test_simple_loop_with_call(self):
@dont_look_inside
More information about the Pypy-commit
mailing list