summaryrefslogtreecommitdiff
path: root/lib/git/async/util.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2010-06-07 23:47:06 +0200
committerSebastian Thiel <byronimo@gmail.com>2010-06-07 23:47:06 +0200
commit898d47d1711accdfded8ee470520fdb96fb12d46 (patch)
treeac2426a03dbc538fb970cd4fd22a404edb68ce53 /lib/git/async/util.py
parente825f8b69760e269218b1bf1991018baf3c16b04 (diff)
downloadgitpython-898d47d1711accdfded8ee470520fdb96fb12d46.tar.gz
Task scheduled items lock now uses a dummy lock in serial mode, improving its performance considerably.
Channels now use the AsyncQueue, boosting their throughput to about 5k items / s - this is something one can work with, considering the runtime of each item should be large enough to keep the threads busy. This could be a basis, further testing needed
Diffstat (limited to 'lib/git/async/util.py')
-rw-r--r--lib/git/async/util.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/git/async/util.py b/lib/git/async/util.py
index 6bd8a4e8..55766579 100644
--- a/lib/git/async/util.py
+++ b/lib/git/async/util.py
@@ -41,6 +41,18 @@ def cpu_count():
#} END routines
+
+class DummyLock(object):
+ """An object providing a do-nothing lock interface for use in sync mode"""
+ __slots__ = tuple()
+
+ def acquire(self):
+ pass
+
+ def release(self):
+ pass
+
+
class SyncQueue(deque):
"""Adapter to allow using a deque like a queue, without locking"""
def get(self, block=True, timeout=None):
@@ -59,7 +71,7 @@ class SyncQueue(deque):
class HSCondition(_Condition):
"""An attempt to make conditions less blocking, which gains performance
in return by sleeping less"""
- delay = 0.0001 # reduces wait times, but increases overhead
+ delay = 0.00002 # reduces wait times, but increases overhead
def wait(self, timeout=None):
waiter = Lock()