da-woods schrieb am 19.09.23 um 21:38:
I think the detail that was missing is you need to add the `#cython: fast_gil = True` to enable it.
[...]
So my conclusion is that from 3.11 onwards Python sped up their own GIL handling to about the same as we used to have, and fastgil has turned into a pessimization.

I tried the benchmark with the master branch on my side again, this time with correct configuration. :)

Turns out that enabling the FastGIL feature makes it much slower for me (on Ubuntu Linux 20.04) in both Py3.8 and 3.10:

"""
* Python 3.10 (-DCYTHON_FAST_GIL=0)
Running the test (already held)...
took 1.2482502460479736
Running the test (released)...
took 6.444956541061401
Running the test (already held)...
took 1.2358744144439697
Running the test (released)...
took 6.4064109325408936

* Python 3.10 (-DCYTHON_FAST_GIL=1)
Running the test (already held)...
took 2.243091583251953
Running the test (released)...
took 7.32707667350769
Running the test (already held)...
took 2.4065449237823486
Running the test (released)...
took 7.50264573097229
"""

I also tried it with PGO enabled and got more or less the same result. The Python installations that I tried it with were both PGO builds.

It's probably mixed across platforms, different configurations and C compilers. I looked through the "What's new" document for Py3.10 and 3.11 but couldn't find mentions of GIL improvements. Just that some other things have become faster.

So – disable the feature in Python 3.11 and later? (Currently it's disabled in 3.12+.)

Py3.11+ would suggest that we keep the code in Cython 3.1, since that will support older Python versions that still seem to benefit from it.

Stefan

_______________________________________________
cython-devel mailing list
cython-devel@python.org
https://mail.python.org/mailman/listinfo/cython-devel

Reply via email to