[pypy-commit] pypy stm-gc: A quick try to see the cost associated with locking this mutex:
arigo
noreply at buildbot.pypy.org
Mon Feb 20 18:19:58 CET 2012
Author: Armin Rigo <arigo at tunes.org>
Branch: stm-gc
Changeset: r52680:b104b62668bd
Date: 2012-02-20 18:19 +0100
http://bitbucket.org/pypy/pypy/changeset/b104b62668bd/
Log: A quick try to see the cost associated with locking this mutex: add
a fast-path if pending.run() adds exactly one new transaction.
diff --git a/pypy/module/transaction/fifo.py b/pypy/module/transaction/fifo.py
--- a/pypy/module/transaction/fifo.py
+++ b/pypy/module/transaction/fifo.py
@@ -16,6 +16,9 @@
assert (self.first is None) == (self.last is None)
return self.first is None
+ def is_of_length_1(self):
+ return self.first is not None and self.first is self.last
+
def popleft(self):
item = self.first
self.first = item.next
diff --git a/pypy/module/transaction/interp_transaction.py b/pypy/module/transaction/interp_transaction.py
--- a/pypy/module/transaction/interp_transaction.py
+++ b/pypy/module/transaction/interp_transaction.py
@@ -247,7 +247,15 @@
if state.pending.is_empty():
state.lock_no_tasks_pending()
state.unlock()
- pending.run()
+ #
+ while True:
+ pending.run()
+ # for now, always break out of this loop, unless
+ # 'my_transactions_pending' contains precisely one item
+ if not my_transactions_pending.is_of_length_1():
+ break
+ pending = my_transactions_pending.popleft()
+ #
state.lock()
_add_list(my_transactions_pending)
#
More information about the pypy-commit
mailing list