Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
gh-115999: Add free-threaded specialization for STORE_SUBSCR#127169
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
colesbury commented Nov 22, 2024 • edited by bedevere-app bot
Loading Uh oh!
There was an error while loading. Please reload this page.
edited by bedevere-app bot
Uh oh!
There was an error while loading. Please reload this page.
The specialization only depends on the type, so no special thread-safety considerations there. STORE_SUBSCR_LIST_INT needs to lock the list before modifying it. `_PyDict_SetItem_Take2` already internally locks the dictionary using a critical section.
Python/ceval_macros.h Outdated
| // avoid any potentially escaping calls (like PyStackRef_CLOSE) while the | ||
| // object is locked. | ||
| #ifdefPy_GIL_DISABLED | ||
| # defineLOCK_OBJECT(op) PyMutex_LockFast(&(_PyObject_CAST(op))->ob_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.
@mpage, I think this locking pattern will be slightly faster than using critical sections inline in bytecodes.c. The downside is that we will deopt if there's any lock contention, but I think that's an okay tradeoff.
If we decide to go with this pattern, we can update UNPACK_SEQUENCE_LIST to use it.
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.
That makes sense to me.
colesbury commented Nov 22, 2024
@corona10 - I put my name down next to |
colesbury commented Nov 22, 2024
( |
mpage left a comment
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.
Nice! I left one comment/question inline and there's a compiler warning that we need to fix up.
Python/ceval_macros.h Outdated
| // avoid any potentially escaping calls (like PyStackRef_CLOSE) while the | ||
| // object is locked. | ||
| #ifdefPy_GIL_DISABLED | ||
| # defineLOCK_OBJECT(op) PyMutex_LockFast(&(_PyObject_CAST(op))->ob_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.
That makes sense to me.
Uh oh!
There was an error while loading. Please reload this page.
corona10 commented Nov 22, 2024
Race condition with the wrong lock :) Fine, thank you for the work, I've updated the list of issues. |
corona10 left a comment
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.
Please add test codes at test_opcache.py
cpython/Lib/test/test_opcache.py
Line 1227 in d24a22e
| classTestSpecializer(TestBase): |
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Donghee Na <donghee.na92@gmail.com>
corona10 left a comment • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
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 (except test code :))
colesbury commented Nov 25, 2024
Performance difference is marginal: 1.00x faster (but 99.99% likely to be faster) I think it's worth doing even if the perf is neutral just to minimize divergence with the default (GIL) build. |
pythongh-127518: Fix pystats build after python#127619
…ython#127169) The specialization only depends on the type, so no special thread-safety considerations there. STORE_SUBSCR_LIST_INT needs to lock the list before modifying it. `_PyDict_SetItem_Take2` already internally locks the dictionary using a critical section.
pythongh-127518: Fix pystats build after python#127619
The specialization only depends on the type, so no special thread-safety considerations there.
STORE_SUBSCR_LIST_INT needs to lock the list before modifying it.
_PyDict_SetItem_Take2already internally locks the dictionary using a critical section.--disable-gilbuilds #115999