[pypy-commit] pypy stm-gc-2: hg merge stm-thread-2
arigo
noreply at buildbot.pypy.org
Sun Apr 7 00:36:19 CEST 2013
Author: Armin Rigo <arigo at tunes.org>
Branch: stm-gc-2
Changeset: r63108:88c864764d5f
Date: 2013-04-06 22:14 +0200
http://bitbucket.org/pypy/pypy/changeset/88c864764d5f/
Log: hg merge stm-thread-2
diff --git a/lib_pypy/pypy_test/test_transaction.py b/lib_pypy/pypy_test/test_transaction.py
--- a/lib_pypy/pypy_test/test_transaction.py
+++ b/lib_pypy/pypy_test/test_transaction.py
@@ -76,6 +76,21 @@
assert num_foos == 1, lsts
+def test_number_of_transactions_reported():
+ transaction.add(lambda: None)
+ transaction.run()
+ assert transaction.number_of_transactions_in_last_run() == 1
+
+ def add_transactions(l):
+ if l:
+ for x in range(l[0]):
+ transaction.add(add_transactions, l[1:])
+
+ transaction.add(add_transactions, [10, 10, 10])
+ transaction.run()
+ assert transaction.number_of_transactions_in_last_run() == 1111
+
+
def run_tests():
for name in sorted(globals().keys()):
if name.startswith('test_'):
diff --git a/lib_pypy/transaction.py b/lib_pypy/transaction.py
--- a/lib_pypy/transaction.py
+++ b/lib_pypy/transaction.py
@@ -96,6 +96,9 @@
tpool.teardown()
tpool.reraise()
+def number_of_transactions_in_last_run():
+ return _thread_pool.transactions_run
+
# ____________________________________________________________
@@ -104,6 +107,7 @@
def __init__(self):
self.num_threads = 4 # XXX default value, tweak
self.in_transaction = False
+ self.transactions_run = None
def setup(self):
# a mutex to protect parts of _grab_next_thing_to_do()
@@ -122,17 +126,20 @@
_thread_local.pending = None
#
self.num_waiting_threads = 0
+ self.transactions_run = 0
self.finished = False
self.got_exception = []
self.in_transaction = True
def run(self):
# start the N threads
- for i in range(self.num_threads):
- thread.start_new_thread(self._run_thread, ())
+ task_counters = [[0] for i in range(self.num_threads)]
+ for counter in task_counters:
+ thread.start_new_thread(self._run_thread, (counter,))
# now wait. When we manage to acquire the following lock, then
# we are finished.
self.lock_if_released_then_finished.acquire()
+ self.transactions_run = sum(x[0] for x in task_counters)
def teardown(self):
self.in_transaction = False
@@ -148,13 +155,14 @@
if exc:
raise exc[0], exc[1], exc[2] # exception, value, traceback
- def _run_thread(self):
+ def _run_thread(self, counter):
tloc_pending = _thread_local.pending
got_exception = self.got_exception
try:
while True:
self._do_it(self._grab_next_thing_to_do(tloc_pending),
got_exception)
+ counter[0] += 1
except _Done:
pass
@@ -249,7 +257,7 @@
header = info[0]
f = cStringIO.StringIO()
if len(info) > 1:
- print >> f, 'Traceback from detected conflict:'
+ print >> f, 'Detected conflict:'
for tb in info[1:]:
filename = tb[0]
coname = tb[1]
diff --git a/rpython/translator/stm/src_stm/et.h b/rpython/translator/stm/src_stm/et.h
--- a/rpython/translator/stm/src_stm/et.h
+++ b/rpython/translator/stm/src_stm/et.h
@@ -93,7 +93,6 @@
//gcptr Allocate(size_t size, int gctid);
_Bool stm_PtrEq(gcptr P1, gcptr P2);
-gcptr stm_HashObject(gcptr P);
void *stm_DirectReadBarrier(void *);
void *stm_DirectReadBarrierFromR(void *, void *, size_t);
More information about the pypy-commit
mailing list