[pypy-svn] r78748 - in pypy/branch/jit-signals/pypy: interpreter interpreter/test module/pypyjit module/signal module/sys
arigo at codespeak.net
arigo at codespeak.net
Fri Nov 5 16:05:34 CET 2010
Author: arigo
Date: Fri Nov 5 16:05:32 2010
New Revision: 78748
Modified:
pypy/branch/jit-signals/pypy/interpreter/executioncontext.py
pypy/branch/jit-signals/pypy/interpreter/test/test_executioncontext.py
pypy/branch/jit-signals/pypy/module/pypyjit/interp_jit.py
pypy/branch/jit-signals/pypy/module/signal/interp_signal.py
pypy/branch/jit-signals/pypy/module/sys/__init__.py
pypy/branch/jit-signals/pypy/module/sys/vm.py
Log:
Allow us to specify the speed at which checkinterval is reached.
For now, jitted loops always take 20 times longer to reach the limit.
Modified: pypy/branch/jit-signals/pypy/interpreter/executioncontext.py
==============================================================================
--- pypy/branch/jit-signals/pypy/interpreter/executioncontext.py (original)
+++ pypy/branch/jit-signals/pypy/interpreter/executioncontext.py Fri Nov 5 16:05:32 2010
@@ -5,6 +5,8 @@
from pypy.rlib.unroll import unrolling_iterable
from pypy.rlib import jit
+TICK_COUNTER_STEP = 100
+
def app_profile_call(space, w_callable, frame, event, w_arg):
space.call_function(w_callable,
space.wrap(frame),
@@ -166,12 +168,12 @@
if self.w_tracefunc is not None:
self._trace(frame, 'return', w_retval)
- def bytecode_trace(self, frame):
+ def bytecode_trace(self, frame, decr_by=TICK_COUNTER_STEP):
"Trace function called before each bytecode."
# this is split into a fast path and a slower path that is
# not invoked every time bytecode_trace() is.
actionflag = self.space.actionflag
- if actionflag.decrement_ticker() < 0:
+ if actionflag.decrement_ticker(decr_by) < 0:
actionflag.action_dispatcher(self, frame) # slow path
bytecode_trace._always_inline_ = True
@@ -333,6 +335,7 @@
self._nonperiodic_actions = []
self.has_bytecode_counter = False
self.fired_actions = None
+ self.checkinterval_scaled = 100 * TICK_COUNTER_STEP
self._rebuild_action_dispatcher()
def fire(self, action):
@@ -361,10 +364,16 @@
self.has_bytecode_counter = True
self._rebuild_action_dispatcher()
- def setcheckinterval(self, space, interval):
+ def getcheckinterval(self):
+ return self.checkinterval_scaled // TICK_COUNTER_STEP
+
+ def setcheckinterval(self, interval):
+ MAX = sys.maxint // TICK_COUNTER_STEP
if interval < 1:
interval = 1
- space.sys.checkinterval = interval
+ elif interval > MAX:
+ interval = MAX
+ self.checkinterval_scaled = interval * TICK_COUNTER_STEP
def _rebuild_action_dispatcher(self):
periodic_actions = unrolling_iterable(self._periodic_actions)
@@ -372,7 +381,7 @@
@jit.dont_look_inside
def action_dispatcher(ec, frame):
# periodic actions (first reset the bytecode counter)
- self.reset_ticker(ec.space.sys.checkinterval)
+ self.reset_ticker(self.checkinterval_scaled)
for action in periodic_actions:
action.perform(ec, frame)
@@ -399,10 +408,10 @@
def reset_ticker(self, value):
self._ticker = value
- def decrement_ticker(self):
+ def decrement_ticker(self, by):
value = self._ticker
if self.has_bytecode_counter: # this 'if' is constant-folded
- value -= 1
+ value -= by
self._ticker = value
return value
Modified: pypy/branch/jit-signals/pypy/interpreter/test/test_executioncontext.py
==============================================================================
--- pypy/branch/jit-signals/pypy/interpreter/test/test_executioncontext.py (original)
+++ pypy/branch/jit-signals/pypy/interpreter/test/test_executioncontext.py Fri Nov 5 16:05:32 2010
@@ -58,7 +58,8 @@
""")
except Finished:
pass
- assert space.sys.checkinterval / 10 < i < space.sys.checkinterval * 1.1
+ checkinterval = space.actionflag.getcheckinterval()
+ assert checkinterval / 10 < i < checkinterval * 1.1
def test_llprofile(self):
l = []
Modified: pypy/branch/jit-signals/pypy/module/pypyjit/interp_jit.py
==============================================================================
--- pypy/branch/jit-signals/pypy/module/pypyjit/interp_jit.py (original)
+++ pypy/branch/jit-signals/pypy/module/pypyjit/interp_jit.py Fri Nov 5 16:05:32 2010
@@ -80,8 +80,9 @@
def jump_absolute(self, jumpto, _, ec=None):
if we_are_jitted():
+ decr_by = 5 # XXX adapt dynamically
self.last_instr = intmask(jumpto)
- ec.bytecode_trace(self)
+ ec.bytecode_trace(self, decr_by)
jumpto = r_uint(self.last_instr)
pypyjitdriver.can_enter_jit(frame=self, ec=ec, next_instr=jumpto,
pycode=self.getcode())
Modified: pypy/branch/jit-signals/pypy/module/signal/interp_signal.py
==============================================================================
--- pypy/branch/jit-signals/pypy/module/signal/interp_signal.py (original)
+++ pypy/branch/jit-signals/pypy/module/signal/interp_signal.py Fri Nov 5 16:05:32 2010
@@ -65,11 +65,11 @@
p = pypysig_getaddr_occurred()
p.c_value = value
- def decrement_ticker(self):
+ def decrement_ticker(self, by):
p = pypysig_getaddr_occurred()
value = p.c_value
if self.has_bytecode_counter: # this 'if' is constant-folded
- value -= 1
+ value -= by
p.c_value = value
return value
Modified: pypy/branch/jit-signals/pypy/module/sys/__init__.py
==============================================================================
--- pypy/branch/jit-signals/pypy/module/sys/__init__.py (original)
+++ pypy/branch/jit-signals/pypy/module/sys/__init__.py Fri Nov 5 16:05:32 2010
@@ -10,7 +10,6 @@
if space.config.translating:
del self.__class__.interpleveldefs['pypy_getudir']
super(Module, self).__init__(space, w_name)
- self.checkinterval = 100
self.recursionlimit = 100
self.w_default_encoder = None
self.defaultencoding = "ascii"
Modified: pypy/branch/jit-signals/pypy/module/sys/vm.py
==============================================================================
--- pypy/branch/jit-signals/pypy/module/sys/vm.py (original)
+++ pypy/branch/jit-signals/pypy/module/sys/vm.py Fri Nov 5 16:05:32 2010
@@ -67,7 +67,7 @@
def setcheckinterval(space, interval):
"""Tell the Python interpreter to check for asynchronous events every
n instructions. This also affects how often thread switches occur."""
- space.actionflag.setcheckinterval(space, interval)
+ space.actionflag.setcheckinterval(interval)
setcheckinterval.unwrap_spec = [ObjSpace, int]
def getcheckinterval(space):
@@ -77,7 +77,7 @@
# return 0. The idea is that according to the CPython docs, <= 0
# means "check every virtual instruction, maximizing responsiveness
# as well as overhead".
- result = space.sys.checkinterval
+ result = space.actionflag.getcheckinterval()
if result <= 1:
result = 0
return space.wrap(result)
More information about the Pypy-commit
mailing list