New submission from Shreyan Avigyan <>:

Today while working on an attempt to improve the GIL (either by modifying it or 
removing it) I noticed that in destroy_gil function first we unlock the mutex 
and then we set the gil->locked to -1 using _Py_atomic_store_explicit. 
Therefore the cycle is, "Unlock -> Atomic_Set_Value" which closely evaluates 
to, "Unlock -> Lock -> Set_Value -> Unlock"

I tweaked around a little and when I changed the cycle to, "Atomic_Set_Value -> 
Unlock" I noticed by running David Beazley's famous benchmarks that there's an 
increase in speed by 0.22 or something like that. I don't know if it's because 
of CPU instability or because of the tweak but it looks like an improvement. 
Should this patch be applied to cpython?

components: C API
messages: 393642
nosy: shreyanavigyan
priority: normal
severity: normal
status: open
title: GIL Improvement
type: performance
versions: Python 3.10, Python 3.11, Python 3.9

Python tracker <>
Python-bugs-list mailing list

Reply via email to