-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
gh-137514: Add a free-threading wrapper for mutexes #137515
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-137514: Add a free-threading wrapper for mutexes #137515
Conversation
@@ -15993,13 +15985,13 @@ intern_common(PyInterpreterState *interp, PyObject *s /* stolen */, | |||
PyObject *interned = get_interned_dict(interp); | |||
assert(interned != NULL); | |||
|
|||
LOCK_INTERNED(interp); |
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 believe it is worth to keep the old interface here. And implement LOCK_INTERNED via FT_MUTEX_LOCK.
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.
Why?
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.
It is shorter, easier to read and less error-prone on my sight.
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.
Hm, instead of adding another locking macro, how about an INTERN_MUTEX
macro that acts as a shorthand for &_Py_INTERP_CACHED_OBJECT(interp, interned_mutex)
.
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.
Looks like a good idea!
@@ -509,9 +502,9 @@ _PyEval_SetProfile(PyThreadState *tstate, Py_tracefunc func, PyObject *arg) | |||
|
|||
// needs to be decref'd outside of the lock | |||
PyObject *old_profileobj; | |||
LOCK_SETUP(); |
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.
Same here. I think it is better to keep the old one.
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 think this one is fine. We already used sys_trace_profile_mutex
inline in pystate.c
.
Do we want this in 3.14? |
Add
FT_MUTEX_LOCK
/FT_MUTEX_UNLOCK
, which callPyMutex_Lock
andPyMutex_Unlock
on the free-threaded build, and no-op otherwise.