[New-bugs-announce] [issue44130] GIL Improvement

Shreyan Avigyan report at bugs.python.org
Fri May 14 08:03:46 EDT 2021

New submission from Shreyan Avigyan <shreyan.avigyan at gmail.com>:

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 <report at bugs.python.org>

More information about the New-bugs-announce mailing list