[Python-Dev] Removing the GIL (Me, not you!)

Adam Olsen rhamph at gmail.com
Fri Sep 14 08:10:17 CEST 2007

On 9/13/07, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> skip at pobox.com wrote:
> > what if ... we use atomic test-and-set to
> > handle reference counting (with a lock for those CPU architectures where we
> > haven't written the necessary assembler fragment), then implement a lock for
> > each mutable type and another for global state (thread state, interpreter
> > state, etc)?
> Could be worth a try. A first step might be to just implement
> the atomic refcounting, and run that single-threaded to see
> if it has terribly bad effects on performance.

I've done this experiment.  It was about 12% on my box.  Later, once I
had everything else setup so I could run two threads simultaneously, I
found much worse costs.  All those literals become shared objects that
create contention.

I'm now working on an approach that writes out refcounts in batches to
reduce contention.  The initial cost is much higher, but it scales
better too.  I've currently got it to just under 50% cost, meaning two
threads is a slight net gain.

Adam Olsen, aka Rhamphoryncus

More information about the Python-Dev mailing list