-
-
Notifications
You must be signed in to change notification settings - Fork 30.5k
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-117657: use relaxed loads for checking dict keys immortality #118067
Conversation
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
@@ -441,7 +441,7 @@ static void free_keys_object(PyDictKeysObject *keys, bool use_qsbr); | |||
static inline void | |||
dictkeys_incref(PyDictKeysObject *dk) | |||
{ | |||
if (dk->dk_refcnt == _Py_IMMORTAL_REFCNT) { | |||
if (FT_ATOMIC_LOAD_SSIZE_RELAXED(dk->dk_refcnt) == _Py_IMMORTAL_REFCNT) { |
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.
We could also do dk == Py_EMPTY_KEYS
and avoid the atomics, but this seems fine too.
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.
I kind of like that, but am a little worried that it'll be overlooked if any other keys become immortal, so I'll just keep it as-is for now.
|
Checking for immortality of dict keys is reported as a TSAN violation, we just need relaxed loads