[pypy-commit] pypy stmgc-c7: Tweaks: rstm.longest_abort_info() turns the transaction inevitable, so we need a different way to inspect it first
arigo
noreply at buildbot.pypy.org
Sat May 3 17:05:27 CEST 2014
Author: Armin Rigo <arigo at tunes.org>
Branch: stmgc-c7
Changeset: r71230:d6678ac9de67
Date: 2014-05-03 12:38 +0200
http://bitbucket.org/pypy/pypy/changeset/d6678ac9de67/
Log: Tweaks: rstm.longest_abort_info() turns the transaction inevitable,
so we need a different way to inspect it first
diff --git a/lib_pypy/atomic.py b/lib_pypy/atomic.py
--- a/lib_pypy/atomic.py
+++ b/lib_pypy/atomic.py
@@ -41,10 +41,11 @@
_fullfilenames = {}
def print_abort_info(mintime=0.0):
- a, b, c, d = _thread.longest_abort_info()
- if b <= mintime:
+ info = _thread.longest_abort_info(mintime)
+ if info is None:
return
print >> sys.stderr, "Conflict",
+ a, b, c, d = info
try:
reason = _timing_reasons[a]
except IndexError:
diff --git a/pypy/module/__pypy__/interp_atomic.py b/pypy/module/__pypy__/interp_atomic.py
--- a/pypy/module/__pypy__/interp_atomic.py
+++ b/pypy/module/__pypy__/interp_atomic.py
@@ -1,4 +1,5 @@
from pypy.interpreter.error import OperationError
+from pypy.interpreter.gateway import unwrap_spec
from pypy.module.thread.error import wrap_thread_error
from rpython.rtyper.lltypesystem import rffi
@@ -59,10 +60,13 @@
else:
return space.wrap(1)
-def longest_abort_info(space):
+ at unwrap_spec(mintime=float)
+def longest_abort_info(space, mintime=0.0):
if space.config.translation.stm:
- from rpython.rlib.rstm import longest_abort_info
- a, b, c, d = longest_abort_info()
+ from rpython.rlib import rstm
+ if rstm.longest_marker_time() <= mintime:
+ return space.w_None
+ a, b, c, d = rstm.longest_abort_info()
return space.newtuple([space.wrap(a), space.wrap(b),
space.wrap(c), space.wrap(d)])
else:
diff --git a/rpython/rlib/rstm.py b/rpython/rlib/rstm.py
--- a/rpython/rlib/rstm.py
+++ b/rpython/rlib/rstm.py
@@ -132,6 +132,10 @@
def pop_marker():
llop.stm_pop_marker(lltype.Void)
+ at dont_look_inside # XXX allow looking inside this function
+def longest_marker_time():
+ return llop.stm_longest_marker_time(lltype.Float)
+
@dont_look_inside
def longest_abort_info():
state = llop.stm_longest_marker_state(lltype.Signed)
diff --git a/rpython/translator/stm/test/test_ztranslated.py b/rpython/translator/stm/test/test_ztranslated.py
--- a/rpython/translator/stm/test/test_ztranslated.py
+++ b/rpython/translator/stm/test/test_ztranslated.py
@@ -268,6 +268,7 @@
setxy(globf, retry_counter)
if retry_counter < 3:
rstm.abort_and_retry()
+ print rstm.longest_marker_time()
print rstm.longest_abort_info()
rstm.reset_longest_abort_info()
print rstm.longest_abort_info()
@@ -286,7 +287,7 @@
data = cbuilder.cmdexec('a b')
#
# 6 == STM_TIME_RUN_ABORTED_OTHER
- import re; r = re.compile(r'\(6, 0.00\d+, , \)\n\(0, 0.00+, , \)\n$')
+ import re; r = re.compile(r'0.00\d+\n\(6, 0.00\d+, , \)\n\(0, 0.00+, , \)\n$')
assert r.match(data)
def test_weakref(self):
More information about the pypy-commit
mailing list