Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

gh-112075: Enable freeing with qsbr and fallback to lock on key changed #116336

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

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions 9 Objects/dictobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,6 @@ set_values(PyDictObject *mp, PyDictValues *values)
_Py_atomic_store_ptr_release(&mp->ma_values, values);
}

// Defined until we get QSBR
#define _PyMem_FreeQsbr PyMem_Free

#define LOCK_KEYS(keys) PyMutex_LockFlags(&keys->dk_mutex, _Py_LOCK_DONT_DETACH)
#define UNLOCK_KEYS(keys) PyMutex_Unlock(&keys->dk_mutex)

Expand Down Expand Up @@ -806,7 +803,7 @@ free_keys_object(PyDictKeysObject *keys, bool use_qsbr)
{
#ifdef Py_GIL_DISABLED
if (use_qsbr) {
_PyMem_FreeQsbr(keys);
_PyMem_FreeDelayed(keys);
return;
}
#endif
Expand Down Expand Up @@ -846,7 +843,7 @@ free_values(PyDictValues *values, bool use_qsbr)
int prefix_size = DICT_VALUES_SIZE(values);
#ifdef Py_GIL_DISABLED
if (use_qsbr) {
_PyMem_FreeQsbr(((char *)values)-prefix_size);
_PyMem_FreeDelayed(((char *)values)-prefix_size);
return;
}
#endif
Expand Down Expand Up @@ -6694,7 +6691,7 @@ _PyObject_StoreInstanceAttribute(PyObject *obj, PyDictValues *values,
#ifdef Py_GIL_DISABLED
// Try a thread-safe lookup to see if the index is already allocated
ix = unicodekeys_lookup_unicode_threadsafe(keys, name, hash);
if (ix == DKIX_EMPTY) {
if (ix == DKIX_EMPTY || ix == DKIX_KEY_CHANGED) {
// Lock keys and do insert
LOCK_KEYS(keys);
ix = insert_into_splitdictkeys(keys, name, hash);
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.