[issue3001] RLock's are SLOW

sebastian serrano report at bugs.python.org
Sat Jun 21 18:40:53 CEST 2008


sebastian serrano <sebastian at devsar.com> added the comment:

Running with python -O the timing gets a little closer between Lock and
RLock. This code won't be easy to improve in performance. 
The heaviest call is current_thread(), used at lines:
117:    me = current_thread()
137:    if self.__owner is not current_thread():

and only consist on:
788: def current_thread():
789:     try:
790:         return _active[_get_ident()]
791:     except KeyError:
792:         ##print "current_thread(): no current thread for", _get_ident()
793:         return _DummyThread()

Simple profiler dump:
$../python-trunk/python -O rlock.py 
time Lock 0.720541000366
time RLock 4.90231084824
         400004 function calls in 0.982 CPU seconds

   Ordered by: internal time, call count

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
   100000    0.304    0.000    0.390    0.000 threading.py:116(acquire)
   100000    0.278    0.000    0.360    0.000 threading.py:136(release)
        1    0.232    0.232    0.982    0.982 rlock.py:27(testRLock)
   200000    0.168    0.000    0.168    0.000
threading.py:788(current_thread)
        1    0.000    0.000    0.000    0.000 threading.py:103(__init__)
        1    0.000    0.000    0.000    0.000 threading.py:98(RLock)
        1    0.000    0.000    0.000    0.000 threading.py:76(__init__)
        0    0.000             0.000          profile:0(profiler)

----------
nosy: +sserrano

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3001>
_______________________________________


More information about the Python-bugs-list mailing list