This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author kristjan.jonsson
Recipients kristjan.jonsson, loewis, pitrou
Date 2012-06-08.18:31:37
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1339180301.31.0.978544490833.issue15038@psf.upfronthosting.co.za>
In-reply-to
Content
The attached patch does three things:

"
- Abstract the condition variable used by ceval_gil.h into a separate file,
condvar.h.  It now defines a PyMUTEX_T, PyCOND_T and associated functions.
This file can be used by different parts of the python core.
- Implement locking on windows using custom structures based on condition
variables, rather than using a semaphore kernel object.  This avoids kernel
transitions for uncontensted locks and provides a large speedup for windows.
- Add a condition variable implementation using native primitives for builds
targeted for Vista.  Experimental and disabled by default.
"

Using this locking mechanism on windows results in a 60% speedup of using uncontested locks, due to the removal of the necessary kernel transition that is required by regular semaphore objects.

Before:
D:\pydev\hg\cpython3\PCbuild\amd64>.\python.exe -m timeit -s "from _thread import allocate_lock; l=allocate_lock()" "l.acquire();l
.release()"
1000000 loops, best of 3: 0.731 usec per loop

After:
D:\pydev\hg\cpython3\PCbuild\amd64>.\python.exe -m timeit -s "from _thread import allocate_lock; l=allocate_lock()" "l.acquire();l
.release()"
1000000 loops, best of 3: 0.27 usec per loop
History
Date User Action Args
2012-06-08 18:31:41kristjan.jonssonsetrecipients: + kristjan.jonsson, loewis, pitrou
2012-06-08 18:31:41kristjan.jonssonsetmessageid: <1339180301.31.0.978544490833.issue15038@psf.upfronthosting.co.za>
2012-06-08 18:31:40kristjan.jonssonlinkissue15038 messages
2012-06-08 18:31:40kristjan.jonssoncreate