-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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-115999: Add free-threaded specialization for SEND
.
#127426
Conversation
No additional thread safety changes are required. Note that sending to a generator that is shared between threads is not safe in the free-threaded build.
Related: GH-126371 makes native generators thread safe for free-threading. Once this gets merged, I can finish that one up and add any needed locking for the specialization instruction. |
I didn't test too much but applying GH-126371 on top of this PR makes the |
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 try to organize unitest codes for specialized opcodes with more understandable function name :)
See:
cpython/Lib/test/test_opcache.py
Lines 1400 to 1418 in c112de1
def binary_subscr_dict(): | |
for _ in range(100): | |
a = {1: 2, 2: 3} | |
self.assertEqual(a[1], 2) | |
self.assertEqual(a[2], 3) | |
binary_subscr_dict() | |
self.assert_specialized(binary_subscr_dict, "BINARY_SUBSCR_DICT") | |
self.assert_no_opcode(binary_subscr_dict, "BINARY_SUBSCR") | |
def binary_subscr_str_int(): | |
for _ in range(100): | |
a = "foobar" | |
for idx, expected in enumerate(a): | |
self.assertEqual(a[idx], expected) | |
binary_subscr_str_int() | |
self.assert_specialized(binary_subscr_str_int, "BINARY_SUBSCR_STR_INT") | |
self.assert_no_opcode(binary_subscr_str_int, "BINARY_SUBSCR") |
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. I left a small suggestion inline to make the implementation of _Py_Specialize_Send
a little more concise, but feel free to ignore it if you prefer the current code structure.
I've kicked off benchmark runs for both the default and free-threaded builds for this change. I'll post the results once they're available, likely tomorrow morning.
Performance looks neutral on both the default and free-threaded builds. I think it's still worth merging this to stay consistent with the default build. |
…h-127426) No additional thread safety changes are required. Note that sending to a generator that is shared between threads is currently not safe in the free-threaded build.
…h-127426) No additional thread safety changes are required. Note that sending to a generator that is shared between threads is currently not safe in the free-threaded build.
No additional thread safety changes are required. Note that sending to a generator that is shared between threads is not safe in the free-threaded build.
--disable-gil
builds #115999