-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
gh-100227: Make the Global Interned Dict Safe for Isolated Interpreters #102925
Merged
ericsnowcurrently
merged 17 commits into
python:main
from
ericsnowcurrently:interned-dict-owned-by-main-interpreter
Mar 23, 2023
Merged
gh-100227: Make the Global Interned Dict Safe for Isolated Interpreters #102925
ericsnowcurrently
merged 17 commits into
python:main
from
ericsnowcurrently:interned-dict-owned-by-main-interpreter
Mar 23, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This was referenced Mar 22, 2023
ericsnowcurrently
added
the
🔨 test-with-refleak-buildbots
Test PR w/ refleak buildbots; report in status section
label
Mar 22, 2023
🤖 New build scheduled with the buildbot fleet by @ericsnowcurrently for commit 22753b3 🤖 If you want to schedule another build, you need to add the 🔨 test-with-refleak-buildbots label again. |
bedevere-bot
removed
the
🔨 test-with-refleak-buildbots
Test PR w/ refleak buildbots; report in status section
label
Mar 22, 2023
This was referenced Mar 22, 2023
Fidget-Spinner
pushed a commit
to Fidget-Spinner/cpython
that referenced
this pull request
Mar 27, 2023
…rpreters (pythongh-102925) This is effectively two changes. The first (the bulk of the change) is where we add _Py_AddToGlobalDict() (and _PyRuntime.cached_objects.main_tstate, etc.). The second (much smaller) change is where we update PyUnicode_InternInPlace() to use _Py_AddToGlobalDict() instead of calling PyDict_SetDefault() directly. Basically, _Py_AddToGlobalDict() is a wrapper around PyDict_SetDefault() that should be used whenever we need to add a value to a runtime-global dict object (in the few cases where we are leaving the container global rather than moving it to PyInterpreterState, e.g. the interned strings dict). _Py_AddToGlobalDict() does all the necessary work to make sure the target global dict is shared safely between isolated interpreters. This is especially important as we move the obmalloc state to each interpreter (pythongh-101660), as well as, potentially, the GIL (PEP 684). python#100227
ericsnowcurrently
added a commit
to ericsnowcurrently/cpython
that referenced
this pull request
Mar 27, 2023
…ted Interpreters (pythongh-102925)" This reverts commit 87be8d9.
ericsnowcurrently
added a commit
that referenced
this pull request
Mar 27, 2023
… Safe for Isolated Interpreters" (gh-103063) This reverts commit 87be8d9. This approach to keeping the interned strings safe is turning out to be too complex for my taste (due to obmalloc isolation). For now I'm going with the simpler solution, making the dict per-interpreter. We can revisit that later if we want a sharing solution.
warsaw
pushed a commit
to warsaw/cpython
that referenced
this pull request
Apr 11, 2023
…rpreters (pythongh-102925) This is effectively two changes. The first (the bulk of the change) is where we add _Py_AddToGlobalDict() (and _PyRuntime.cached_objects.main_tstate, etc.). The second (much smaller) change is where we update PyUnicode_InternInPlace() to use _Py_AddToGlobalDict() instead of calling PyDict_SetDefault() directly. Basically, _Py_AddToGlobalDict() is a wrapper around PyDict_SetDefault() that should be used whenever we need to add a value to a runtime-global dict object (in the few cases where we are leaving the container global rather than moving it to PyInterpreterState, e.g. the interned strings dict). _Py_AddToGlobalDict() does all the necessary work to make sure the target global dict is shared safely between isolated interpreters. This is especially important as we move the obmalloc state to each interpreter (pythongh-101660), as well as, potentially, the GIL (PEP 684). python#100227
warsaw
pushed a commit
to warsaw/cpython
that referenced
this pull request
Apr 11, 2023
…obal Interned Dict Safe for Isolated Interpreters" (pythongh-103063) This reverts commit 87be8d9. This approach to keeping the interned strings safe is turning out to be too complex for my taste (due to obmalloc isolation). For now I'm going with the simpler solution, making the dict per-interpreter. We can revisit that later if we want a sharing solution.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is effectively two changes. The first (the bulk of the change) is where we add
_Py_AddToGlobalDict()
(and_PyRuntime.cached_objects.main_tstate
, etc.). The second (much smaller) change is where we updatePyUnicode_InternInPlace()
to use_Py_AddToGlobalDict()
instead of callingPyDict_SetDefault()
directly.Basically,
_Py_AddToGlobalDict()
is a wrapper aroundPyDict_SetDefault()
that should be used whenever we need to add a value to a runtime-global dict object (in the few cases where we are leaving the container global rather than moving it toPyInterpreterState
, e.g. the interned strings dict)._Py_AddToGlobalDict()
does all the necessary work to make sure the target global dict is shared safely between isolated interpreters. This is especially important as we move the obmalloc state to each interpreter (gh-101660), as well as, potentially, the GIL (PEP 684).(This is an alternative to #102339, where we keep the interned dict global instead of making it per-interpreter.)