GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-115999: Add free-threaded specialization for `SEND`. by nascheme · Pull Request #127426 · python/cpython Conversation
|
|
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. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
I didn't test too much but applying GH-126371 on top of this PR makes the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem 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") |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem 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.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
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. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…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.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.