[pypy-commit] benchmarks default: make threadworms use a deque() because a linked list is better for STM
Raemi
noreply at buildbot.pypy.org
Mon May 5 18:01:50 CEST 2014
Author: Remi Meier <remi.meier at inf.ethz.ch>
Branch:
Changeset: r260:0ccaad335031
Date: 2014-05-05 18:01 +0200
http://bitbucket.org/pypy/benchmarks/changeset/0ccaad335031/
Log: make threadworms use a deque() because a linked list is better for
STM
diff --git a/multithread/common/abstract_threading.py b/multithread/common/abstract_threading.py
--- a/multithread/common/abstract_threading.py
+++ b/multithread/common/abstract_threading.py
@@ -1,8 +1,15 @@
from Queue import Queue, Empty, Full
-from threading import Thread, Condition, Lock, local
+from threading import Thread, Condition, RLock, local
import thread, atexit, sys, time
-from atomic import atomic, getsegmentlimit, print_abort_info
+try:
+ from atomic import atomic, getsegmentlimit, print_abort_info
+except:
+ atomic = RLock()
+ def getsegmentlimit():
+ return 1
+ def print_abort_info(tm=0.0):
+ pass
class TLQueue_concurrent(object):
@@ -102,6 +109,7 @@
def shutdown(self):
for w in self.workers:
+ self.input_queue.put((print_abort_info, (), {}))
self.input_queue.put((sys.exit, (), {}))
for w in self.workers:
w.join()
diff --git a/multithread/threadworms/threadworms.py b/multithread/threadworms/threadworms.py
--- a/multithread/threadworms/threadworms.py
+++ b/multithread/threadworms/threadworms.py
@@ -130,9 +130,16 @@
NUM_WORMS = int(worms)
NUM_STEPS = int(steps) // NUM_WORMS
- GRID = []
+ # using a deque instead of a list is kind of cheating
+ # since it is a linked list of blocks. This means
+ # that there are less conflicts.
+ # So maybe remove this again when we support array-barriers in STM
+ import collections
+ list_to_use = collections.deque #list
+
+ GRID = list_to_use()
for x in range(CELLS_WIDE):
- GRID.append([None] * CELLS_HIGH)
+ GRID.append(list_to_use([None] * CELLS_HIGH))
#GRID_LOCK = threading.Lock() # pun was not intended
# Draw some walls on the grid
More information about the pypy-commit
mailing list