[pypy-commit] pypy stm-gc: Found out how to re-enable the methodcache with stm. Trying it out...

arigo noreply at buildbot.pypy.org
Mon Feb 20 13:55:10 CET 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: stm-gc
Changeset: r52673:907d77791735
Date: 2012-02-20 13:53 +0100
http://bitbucket.org/pypy/pypy/changeset/907d77791735/

Log:	Found out how to re-enable the methodcache with stm. Trying it
	out...

diff --git a/pypy/config/pypyoption.py b/pypy/config/pypyoption.py
--- a/pypy/config/pypyoption.py
+++ b/pypy/config/pypyoption.py
@@ -359,9 +359,6 @@
     type_system = config.translation.type_system
     backend = config.translation.backend
 
-    if config.translation.stm:   # XXX --- for STM ---
-        config.objspace.std.withmethodcache = False
-
     # all the good optimizations for PyPy should be listed here
     if level in ['2', '3', 'jit']:
         config.objspace.opcodes.suggest(CALL_METHOD=True)
diff --git a/pypy/interpreter/executioncontext.py b/pypy/interpreter/executioncontext.py
--- a/pypy/interpreter/executioncontext.py
+++ b/pypy/interpreter/executioncontext.py
@@ -36,6 +36,11 @@
         self.compiler = space.createcompiler()
         self.profilefunc = None        # if not None, no JIT
         self.w_profilefuncarg = None
+        #
+        config = self.space.config
+        if config.translation.stm and config.objspace.std.withmethodcache:
+            from pypy.objspace.std.typeobject import MethodCache
+            self._methodcache = MethodCache(self.space)
 
     def gettopframe(self):
         return self.topframeref()
diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py
--- a/pypy/objspace/std/typeobject.py
+++ b/pypy/objspace/std/typeobject.py
@@ -405,7 +405,12 @@
     @elidable
     def _pure_lookup_where_with_method_cache(w_self, name, version_tag):
         space = w_self.space
-        cache = space.fromcache(MethodCache)
+        if space.config.translation.stm:
+            # with stm, it's important to use one method cache per thread;
+            # otherwise, we get all the time spurious transaction conflicts.
+            cache = space.getexecutioncontext()._methodcache
+        else:
+            cache = space.fromcache(MethodCache)
         SHIFT2 = r_uint.BITS - space.config.objspace.std.methodcachesizeexp
         SHIFT1 = SHIFT2 - 5
         version_tag_as_int = current_object_addr_as_int(version_tag)


More information about the pypy-commit mailing list