[issue8299] Improve GIL in 2.7
Kristján Valur Jónsson
report at bugs.python.org
Sat Apr 3 12:27:25 CEST 2010
New submission from Kristján Valur Jónsson <kristjan at ccpgames.com>:
This patch does several things:
1) Creates a separate lock type PyThread_type_gil and locking functions for that. This allows tweaking of the GIL without affecting regular lock behaviour.
2) Creates a uniform implementation of the GIL on windows/pthreads using macros, with emulated condition variables on windows (Lifted Antoine's code from py3k, adding own improvements to the slightly problematic windows implementation). This makes the GIL behave the same on windows and pthreads platforms, if we so choose, and allows cross-platform development.
3) provide three GIL implementations:
a) legacy gil, which is the same as the one used on pthreads
b) a roundrobin gil, which fixes the multicore problem on pthreads and exhibits the same behaviour as the legacy GIL on windows did (no jumping the gil queue)
c) a priority based gil, with n given priority levels, and optionally, the ability to request immediate GIL drop by the ceval.c loop.
See thread_gil.h for details of the three modes.
In my experiments using David Beazley's scripts from http://www.dabeaz.com/blog/dablog.html, implementation "b" fixed the performance problems encountered on multicore machines. This is, I believe, the original impetus for Antoine Pitrou's work on the new GIL.
Implementation "c" improved data transfer still, by allowing faster wakeup of completed IO.
Please note that I was not able to test this patch on a pthreads machine, I can only hope that it compiles :)
components: Interpreter Core
keywords: patch, patch
nosy: beazley, krisvale, pitrou
title: Improve GIL in 2.7
versions: Python 2.7
Added file: http://bugs.python.org/file16744/gil.patch
Python tracker <report at bugs.python.org>
More information about the Python-bugs-list