[Python-ideas] Remove GIL with CAS instructions?

Collin Winter collinw at gmail.com
Tue Nov 24 20:21:05 CET 2009


On Tue, Nov 24, 2009 at 11:10 AM, Guido van Rossum <guido at python.org> wrote:
> Note that Greg Stein reached this same conclusion (and similar
> numbers) over 10 years ago...

It's worth repeating this kind of experiment; the hardware landscape
has changed a lot in 10 years. It's interesting that the results are
the same a decade later.

Collin

> On Tue, Nov 24, 2009 at 10:39 AM, Antoine Pitrou <solipsis at pitrou.net> wrote:
>>
>> Ok, out of curiousity I gave it a try: replacing INCREF/DECREF with atomic
>> instructions (*) slows down the interpreter by 20 to 40% depending on the
>> workload. And keep in mind this is the tip of the iceberg: to remove the GIL
>> you'd also have to add fine-grained locking in other places (dicts etc.).
>>
>> Which makes me agree with the commonly expressed opinion that CPython would
>> probably need to ditch refcounting (at least in the critical paths) if we want
>> to remove the GIL.
>>
>> Regards
>>
>> Antoine.
>>
>>
>> (*) using gcc's atomic primitives which, I have checked, are inlined as
>> carefully optimized assembler:
>> http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Atomic-Builtins.html#Atomic-Builtins
>>
>>
>> _______________________________________________
>> Python-ideas mailing list
>> Python-ideas at python.org
>> http://mail.python.org/mailman/listinfo/python-ideas
>>
>
>
>
> --
> --Guido van Rossum (python.org/~guido)
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>



More information about the Python-ideas mailing list