xeon hyperthreading & GIL

Aahz aahz at pythoncraft.com
Fri Feb 7 11:16:36 EST 2003


In article <1044623847.893400 at ananke.eclipse.net.uk>,
Seb Bacon  <seb.bacon at jamkit.com> wrote:
>
>Let me try again:
>
>Currently python's global interpreter lock will often cause SMP system 
>performance to *decrease* due to the cost of context switching.

Wrong.  It's not the cost of context switching that causes the
performance decrease (or at least no more than for an equivalent C
program).  It's the inability to schedule multiple simultaneous Python
threads.  In order to get a performance boost (and this applies to
single-CPU machines just as much as SMP), you need to call out to an
extension that releases the GIL.

The only difference between single-CPU and SMP is WRT an extension that
does pure CPU work.  So far, few (if any) Python extensions release the
GIL for CPU work; it's almost all I/O extensions.

Overall, for an SMP machine, it's probably going to be easier to run
multiple processes.  Use Twisted to help with the framework.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

Register for PyCon now!  http://www.python.org/pycon/reg.html




More information about the Python-list mailing list