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-134584: Eliminate redundant refcounting from _CALL_TYPE_1#135818
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
tomasr8 commented Jun 22, 2025 • 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.
19ed708 to 184d8f1CompareUh oh!
There was an error while loading. Please reload this page.
Fidget-Spinner 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.
Looks mostly good, just 2 comments that also explain the CI failure.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
tomasr8 commented Jun 22, 2025
Thanks for the review! I'll continue working on it tomorrow (Monday) 🙂 |
Fidget-Spinner commented Jun 23, 2025
I just merged #135761 in. Sorry but you'll have to merge the changes in, as I did not ultimately add |
184d8f1 to 85ab405CompareUh oh!
There was an error while loading. Please reload this page.
Fidget-Spinner 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.
Yay, thank you!
Fidget-Spinner commented Jun 23, 2025
I will do some microbenchmarking to see if this does anything. Give me a sec. |
Fidget-Spinner commented Jun 23, 2025 • 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.
On this script: So it's slightly faster. However, note that this optimization won't fully pay off till we get #135465 merged. So let's wait for now till then. Thanks! Basically right now there's the extra cost of reading and writing to the stack due to the extra _POP_TOP. We're eliminating 1 reference count check in return. This seems to be barely worth it, but I crunched the numbers before and once the stack becomes registers, it becomes very worth it. If you're interested, I benchmarked my own branch with this (higher is better): So we should expect to see an around ~10% speedup once TOS caching is merged, and we start doing this! |
Fidget-Spinner commented Jun 23, 2025
@tomasr8 congrats!!! I decreased the loop count, rebased your PR on top of Mark's TOS caching PR, and did a micro bench with the script above. So 8% improvement if we have TOS caching enabled on |
tomasr8 commented Jun 23, 2025
Awesome stuff! And a pretty nice speedup for a relatively simple optimization too! |
Python/bytecodes.c Outdated
| } | ||
| tier2 op(_SWAP_CALL_ONE_LOAD_CONST_INLINE_BORROW, (ptr/4, callable, null, arg -- value, a)){ | ||
| PyStackRef_CLOSE(arg); |
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.
This shouldn't be here, right? Because we're leaving arg on the stack in a?
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.
Veery late response 😅 but I changed and renamed this op to _SHUFFLE_2_LOAD_CONST_INLINE_BORROW since it's analogous to the recently added _SHUFFLE_3_LOAD_CONST_INLINE_BORROW. This also resolves the issue with closing the ref! :)
tomasr8 commented Dec 23, 2025
I think it should be good now! Though I haven't yet caught up on the latest changes in the JIT so another pair of eyes would be nice :) |
Fidget-Spinner 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.
Just one change, otherwise LGTM!
Uh oh!
There was an error while loading. Please reload this page.
Fidget-Spinner commented Dec 23, 2025
Windows failure is unrelated. Probably due to the other known bug in executor management. I'm merging this, and will be responsible for any breakages/reverts. Thank Tomas, and happy holidays! |
25c294b into python:mainUh oh!
There was an error while loading. Please reload this page.
tomasr8 commented Dec 23, 2025
Thanks for the review, Ken! Happy holidays to you as well! :) |
Depends on #135761