gh-143414: Implement unique reference tracking for JIT, optimize unpacking of such tuples#144300
Conversation
|
Discussed with @Fidget-Spinner, will reopen the PR after implementing |
|
Windows Ci failure looks possibly related, can you please look into it? |
Fidget-Spinner
left a comment
There was a problem hiding this comment.
This is excellent. Just 2 comments, then I think it's safe to merge.
Python/optimizer_bytecodes.c
Outdated
|
|
||
| op(_COPY, (bottom, unused[oparg-1] -- bottom, unused[oparg-1], top)) { | ||
| assert(oparg > 0); | ||
| bottom = PyJitRef_IsUnique(bottom) ? PyJitRef_StripReferenceInfo(bottom) : bottom; |
There was a problem hiding this comment.
We only need to strip unique info here, not the borrow info too. This way we still get refcount elimination with the borrow.
There was a problem hiding this comment.
I think this is consistent with the code?
If the ref is unique, we remove the unique tag, otherwise we leave it as is. Since a ref cannot be both unique and borrowed at the same time, borrowed/invalid refs will be maintained.
|
I have made the requested changes; please review again. Thanks! |
|
Thanks for making the requested changes! @markshannon: please review the changes made to this pull request. |
|
@markshannon Hi mark, please take a look at this PR when you have the time. Thanks! |
|
@reidenong sorry can you please merge in main to this PR? I'll try to get this in this week. |
Mark's review has already been addressed and given 2 weeks for a response.
…8577 * 'main' of github.com:python/cpython: pythongh-146197: Run -m test.pythoninfo on the Emscripten CI (python#146332) pythongh-146325: Use `test.support.requires_fork` in test_fastpath_cache_cleared_in_forked_child (python#146330) pythongh-146197: Add Emscripten to CI (python#146198) pythongh-143387: Raise an exception instead of returning None when metadata file is missing. (python#146234) pythongh-108907: ctypes: Document _type_ codes (pythonGH-145837) pythongh-146175: Soft-deprecate outdated macros; convert internal usage (pythonGH-146178) pythongh-146056: Rework ref counting in treebuilder_handle_end() (python#146167) Add a warning about untrusted input to `configparser` docs (python#146276) pythongh-145264: Do not ignore excess Base64 data after the first padded quad (pythonGH-145267) pythongh-146308: Fix error handling issues in _remote_debugging module (python#146309) pythongh-146192: Add base32 support to binascii (pythonGH-146193) pythongh-135953: Properly obtain main thread identifier in Gecko Collector (python#146045) pythongh-143414: Implement unique reference tracking for JIT, optimize unpacking of such tuples (pythonGH-144300) pythongh-146261: Fix bug in `_Py_uop_sym_set_func_version` (pythonGH-146291) pythongh-145144: Add more tests for UserList, UserDict, etc (pythonGH-145145) pythongh-143959: Fix test_datetime if _datetime is unavailable (pythonGH-145248) pythongh-146245: Fix reference and buffer leaks via audit hook in socket module (pythonGH-146248) pythongh-140049: Colorize exception notes in `traceback.py` (python#140051) Update docs for pythongh-146056 (pythonGH-146213)
|
FYI: Adding unique reference tracking for lists is possible in a similar way as done for tuples in this PR. A prototype is main...eendebakpt:cpython:unique_list. Performance improves, but I am not sure unique list unpacking is as relevant as tuple unpackage @Fidget-Spinner |
Some notes:
_BUILD_TUPLE, to be extended to other objects in the future_LOAD_FAST_*and_COPY.Would appreciate any feedback.
Thanks
unique reference trackingin Tier 2 for reference count optimizations #143414