[pypy-commit] pypy mapdict-interp: Tweak even more. Results are not satisfying, so it will be
arigo
noreply at buildbot.pypy.org
Wed May 18 12:46:18 CEST 2011
Author: Armin Rigo <arigo at tunes.org>
Branch: mapdict-interp
Changeset: r44275:bbc85bbd9806
Date: 2011-05-18 08:17 +0000
http://bitbucket.org/pypy/pypy/changeset/bbc85bbd9806/
Log: Tweak even more. Results are not satisfying, so it will be backed
out for now.
diff --git a/pypy/objspace/std/mapdict.py b/pypy/objspace/std/mapdict.py
--- a/pypy/objspace/std/mapdict.py
+++ b/pypy/objspace/std/mapdict.py
@@ -1,5 +1,6 @@
import weakref
from pypy.rlib import jit, objectmodel, debug
+from pypy.rlib.objectmodel import we_are_translated
from pypy.rlib.rarithmetic import intmask, r_uint
from pypy.rlib import rerased
@@ -718,7 +719,8 @@
INVALID_CACHE_ENTRY.map_wref = weakref.ref(_invalid_cache_entry_map)
# different from any real map ^^^
INVALID_CACHE_ENTRY.index = 0
-REBUILD_CACHE_FREQUENCY = 5 # xxx tweak?
+REBUILD_CACHE_DECR = 24 # xxx tweak? corresponds for now to
+REBUILD_CACHE_INCR = 127 # "every 5 or 6 iterations"
def init_mapdict_cache(pycode):
@@ -726,11 +728,13 @@
pycode._mapdict_caches = [INVALID_CACHE_ENTRY] * num_entries
def _rebuild_cache_now():
- if INVALID_CACHE_ENTRY.index == 0:
- INVALID_CACHE_ENTRY.index = REBUILD_CACHE_FREQUENCY - 1
+ if not we_are_translated(): # to get reproductible and testable results
+ return True
+ INVALID_CACHE_ENTRY.index -= REBUILD_CACHE_DECR
+ if INVALID_CACHE_ENTRY.index < 0:
+ INVALID_CACHE_ENTRY.index += REBUILD_CACHE_INCR
return True
else:
- INVALID_CACHE_ENTRY.index -= 1
return False
_rebuild_cache_now._always_inline_ = True
diff --git a/pypy/objspace/std/test/test_mapdict.py b/pypy/objspace/std/test/test_mapdict.py
--- a/pypy/objspace/std/test/test_mapdict.py
+++ b/pypy/objspace/std/test/test_mapdict.py
@@ -2,12 +2,6 @@
from pypy.objspace.std.test.test_dictmultiobject import FakeSpace, W_DictMultiObject
from pypy.objspace.std.mapdict import *
-def setup_module(mod):
- # force this value to 1 during testing...
- from pypy.objspace.std import mapdict
- mapdict.REBUILD_CACHE_FREQUENCY = 1
-
-
space = FakeSpace()
class Class(object):
More information about the pypy-commit
mailing list