[Python-ideas] Remove GIL with CAS instructions?

Adam Olsen rhamph at gmail.com
Wed Oct 21 02:00:29 CEST 2009

On Tue, Oct 20, 2009 at 17:50, Antoine Pitrou <solipsis at pitrou.net> wrote:
> Sturla Molden <sturla at ...> writes:
>> Yes, one could add a nonsence CAS to existing incref/decref, and measure
>> overhead.
> That would be the first thing to do IMO.
> If it doesn't seem to decrease performance a lot, you could continue by adding
> locking to dict objects, and measure again.
> Then add lists and sets (although I doubt sets and even lists are
> performance-critical for general interpreter operation).
> If after that you have less than a 10% slowdown (personal opinion only, other
> people's mileage may vary), it's probably worth going on and trying to do the
> whole GIL removal (which doesn't mean it would necessarily be accepted, by the
> way, but at least would avoid it being automatically rejected ;-)).

This'd show you the minimum amount of overhead, but only for a trivial
case: single threaded.  You're not invoking cache contention, which in
my experience is much larger than the atomic op cost, and prevents the
*real* gains you hope to make.

Python-safethread makes the datastructures safe (lockless fast-paths)
so that it can be compared properly.  I tried atomic refcounting and
it sucked.  My buffered bodge sucked less, but still sucked.  The only
option left is a real tracing GC.

Adam Olsen, aka Rhamphoryncus

More information about the Python-ideas mailing list