[Python-Dev] GIL removal question

Sturla Molden sturla at molden.no
Wed Aug 17 17:22:22 CEST 2011


Den 10.08.2011 13:43, skrev Guido van Rossum:
> They have a specific plan, based on Software Transactional Memory:
> http://morepypy.blogspot.com/2011/06/global-interpreter-lock-or-how-to-kill.html
>

Microsoft's experiment to use STM in .NET failed though. And Linux got 
rid of the BKL without STM.

There is a similar but simpler paradim called "bulk synchronous 
parallel" (BSP) which might work too. Threads work independently for a 
particular amount of time with private objects (e.g. copy-on-write 
memory), then enter a barrier, changes to global objects are 
synchronized and the GC collects garbage, after which worker threads 
leave the barrier, and the cycle repeats.

To communicate changes to shared objects between synchronization 
barriers, Python code must use explicit locks and flush statements. But 
for the C code in the interpreter, BSP should give the same atomicity 
for Python bytecodes as the GIL  (there is just one active thread inside 
the barrier).

BSP is much simpler to implement than STM because of the barrier 
synchronization. BSP also cannot deadlock or livelock. And because 
threads in BSP work with private memory, there will be no trashing 
(false sharing) from the reference counting GC.

Sturla






More information about the Python-Dev mailing list