giljoy 0.1: Find which C functions are holding the global interpreter lock (GIL)
itamar at itamarst.org
Tue Jul 20 15:43:04 CEST 2010
Ever wondered which C extension functions ought to be releasing the
global interpreter lock? giljoy might be able to help.
Giljoy helps you find C functions that are holding the GIL; in some
cases they could release the GIL, thus making your program more
concurrent. The program uses sampling, so it finds the functions that
most frequently hold the GIL, and may miss infrequently called
Theory of operation: a preloaded module sets a C variable indicating
which thread has GIL. A separate program attaches gdb and then inspects
the C variable.
= Supported Platforms =
The program was only tested on Ubuntu 10.4 with Python 2.6; it will
probably only run on modern versions of Linux. Since it involves large
amounts of duct tape and magic pixie dust, it may not work without
some tweaking -- please let me know if you have any problems!
= Requirements =
pygdb 0.2: http://code.google.com/p/pygdb/
Python with debug symbols (e.g. "apt-get install python2.6-dbg" on
= Sample Output =
Here you can see a large chunk of the time the GIL is held by a C
function that ought to release the GIL (nogil_sleep, which calls usleep
which calls nanosleep). The rest of the time the GIL is held by internal
Python functions that cannot be changed.
$ ./giljoy example.py
Functions that held GIL, by percentage seen (194 samples):
... etc. ...
More information about the Python-announce-list