Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
gh-116167: Allow disabling the GIL with PYTHON_GIL=0 or -X gil=0#116338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Conversation
swtaarrs commented Mar 4, 2024 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
swtaarrs commented Mar 4, 2024
!buildbot nogil |
bedevere-bot commented Mar 4, 2024
🤖 New build scheduled with the buildbot fleet by @swtaarrs for commit ac24233 🤖 The command will test the builders whose names match following regular expression: The builders matched are:
|
In free-threaded builds, running with `PYTHON_GIL=0` will now disable the GIL. Follow-up issues track work to re-enable the GIL when loading an incompatible extension, and to disable the GIL by default. In order to support re-enabling the GIL at runtime, all GIL-related data structures are initialized as usual, and disabling the GIL simply sets a flag that causes `take_gil()` and `drop_gil()` to return early. With `PYTHON_GIL=0` set, I spot-checked a few tests and small programs that don't use threads. They all seem to run fine, and very basic threaded programs work, sometimes. Trying to run the full test suite crashes pretty quickly, in `test_asyncio`.
ac24233 to 9e03999Compareswtaarrs commented Mar 5, 2024
!buildbot nogil |
bedevere-bot commented Mar 5, 2024
🤖 New build scheduled with the buildbot fleet by @swtaarrs for commit 9e03999 🤖 The command will test the builders whose names match following regular expression: The builders matched are:
|
corona10 left a comment • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to add test case in this file too.
cpython/Lib/test/test_cmd_line.py
Line 896 in 72714c0
| deftest_int_max_str_digits(self): |
corona10 commented Mar 5, 2024 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
You can just add the testcase for the environment variable, still worth to adding it. |
corona10 commented Mar 5, 2024
At not for this PR, since this feature is not officially announced, but in some moment, you should write about the environment variable at https://github.com/python/cpython/blob/72714c0266ce6d39c7c7fb63f617573b8f5a3cb2/Doc/using/cmdline.rst to get user feedback. |
swtaarrs commented Mar 5, 2024
!buildbot nogil |
bedevere-bot commented Mar 5, 2024
🤖 New build scheduled with the buildbot fleet by @swtaarrs for commit 4f43a87 🤖 The command will test the builders whose names match following regular expression: The builders matched are:
|
swtaarrs commented Mar 5, 2024
What would be a good time to do that? Maybe once the GIL is disabled by default, so the description doesn't have to change? |
Uh oh!
There was an error while loading. Please reload this page.
colesbury commented Mar 6, 2024 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
I would document the environment variable now, when it's added. For reference, we already document the I don't think it needs to be extensive, but should cover:
The behavior when then environment variable is not set is what's going to change in the future. We can document that later. |
swtaarrs commented Mar 7, 2024
After discussion in Discord, I'm also going to add a |
PYTHON_GIL=0PYTHON_GIL=0 or -X gil=0
ericsnowcurrently left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I've left one minor comment about an unclear test. It really isn't a blocker, as the test is passing, but it would still be nice to have a response.
Uh oh!
There was an error while loading. Please reload this page.
vstinner commented Mar 11, 2024
This is both exciting and very scary. Congrats @swtaarrs and @colesbury :-) |
In free-threaded builds, running with
PYTHON_GIL=0or-X gil=0will now disable the GIL. #116322 and #116329 track follow-up work to re-enable the GIL when loading an incompatible extension, and to disable the GIL by default, respectively.In order to support re-enabling the GIL at runtime, all GIL-related data structures are initialized as usual, and disabling the GIL simply sets a flag at startup that causes
take_gil()anddrop_gil()to return early.With
PYTHON_GIL=0set, I spot-checked a few tests and small programs that don't use threads. They all seem to run fine, and very basic threaded programs work, sometimes. Trying to run the full test suite crashes pretty quickly, intest_asyncio.