New submission from Kristján Valur Jónsson <krist...@ccpgames.com>:
This patch is based on work previously done locally in python 2.7, see http://blog.ccpgames.com/kristjan/2012/05/25/optimizing-python-condition-variables-with-telemetry/ The idea is to acquire the signaling Lock() of the threading.Condition object _and_ the outer lock, without releasing and re-aquiring the GIL in between that is, as an atomic operation from the program's point of view. _thread.LockType objects, used by the Condition object, now have an _acquire_condition method which knows how to do it for LockType and RLock objects. Both lock types grow _release_save and _acquire_restore methods, the latter of which is a no-op. _acquire_coindition() will ignore any other kinds of locks, including subclasses (if such things exist). The result of this is a very marked improvement in signaling time on a contested machine. A file, queuetest.py is provided which measures the wakeup delay. Typical before the change: best: totaltime: 0.167006, avg delay: 0.004766, delay_stddev: 0.002058 typical: totaltime: 0.154271, avg delay: 0.027621, delay_stddev: 0.007479 after the change typical: totaltime: 0.169217, avg delay: 0.001410, delay_stddev: 0.000722 ---------- components: Interpreter Core, Library (Lib) files: condition.patch keywords: patch messages: 163423 nosy: kristjan.jonsson priority: normal severity: normal status: open title: Speed up threading.Condition wakeup type: performance versions: Python 3.3 Added file: http://bugs.python.org/file26085/condition.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue15139> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com