| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
| _Py_DecRefTotal(_PyInterpreterState_GET()); | ||
| #endif | ||
| if (--dk->dk_refcnt == 0) { | ||
| if (_Py_atomic_add_ssize(&dk->dk_refcnt, -1) == 1) { |
There was a problem hiding this comment.
How about adding a macro for the free-threading version and the default version?
Sorry, something went wrong.
There was a problem hiding this comment.
I did similar approach at listobject: 393cbef
See: _Py_SET_ITEMREF
Sorry, something went wrong.
There was a problem hiding this comment.
@corona10 is there a significant difference in performance between the two builds? I'm not sure if it is worth it to add these preprocessor guards everywhere if there is no measurable effect :) Is there a different motivation than performance?
Sorry, something went wrong.
There was a problem hiding this comment.
Regardless of whether we do the macro approach everywhere, I think it's a good idea in this specific case (specifically for performance).
Sorry, something went wrong.
There was a problem hiding this comment.
This mostly looks good to me.
I don't think we want to be locking around shared_keys_usable_size(). It's both not sufficient for thread-safety at most of the call sites and not what we want to be doing for performance reasons.
Sorry, something went wrong.
| _Py_atomic_store_ssize(&keys->dk_nentries, keys->dk_nentries + 1); | ||
| _Py_atomic_store_ssize(&keys->dk_usable, keys->dk_usable - 1); |
There was a problem hiding this comment.
We can use a weaker ordering here that will be faster, especially on x86 where "release" doesn't require any memory barrier:
_Py_atomic_store_ssize_relaxed(&keys->dk_nentries, keys->dk_nentries + 1);
_Py_atomic_store_ssize_release(&keys->dk_usable, keys->dk_usable - 1);
(I don't think we have _Py_atomic_store_ssize_release yet, though)
I find the memory orderings hard to reason correctly about, so I like to model them with CDSChecker. Here's the model I used for this:
https://github.com/colesbury/c11-model-checker/blob/cpython-models/test/gh-112075.c
Sorry, something went wrong.
There was a problem hiding this comment.
One minor formatting comment, but otherwise LGTM
Sorry, something went wrong.
| if (_PyDict_HasSplitTable(mp)) { | ||
| LOCK_KEYS(keys); | ||
| dictkeys_incref(keys); | ||
| } else { |
There was a problem hiding this comment.
| } else { | |
| } | |
| else { |
Sorry, something went wrong.
Adds locking for shared PyDictKeysObject's for dictionaries
Adds locking for shared PyDictKeysObject's for dictionaries
Adds locking for shared PyDictKeysObject's for dictionaries
| Back | FazBrowse Home | New Git URL |
Adds locking for shared keys