-
-
Notifications
You must be signed in to change notification settings - Fork 31.5k
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
bpo-38310: Predict BUILD_MAP_UNPACK_WITH_CALL -> CALL_FUNCTION_EX. #16467
Conversation
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.
Let's limit this to just "BUILD_MAP_UNPACK_WITH_CALL -> CALL_FUNCTION_EX". Since the has a 100% prediction rate and and because it can occur in performance sensitive code.
The others are low payoff and possibly negative payoff in some code (due to the added cost in the mispredicted state). BUILD_CLASS is almost never part of performance sensitive code (we tend to build a class once and use it many time). Also, asserts are rarely part of performance sensitive code (either we turn them off with -O or hoist them out of loop) and actually failing with a LOAD_ASSERTION_ERROR is literally the exceptional case. Further the prediction rate is highly dependent on the particular code snippet in question.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase And if you don't make the requested changes, you will be put in the comfy chair! |
452edaa
to
ee7c100
Compare
Thank @rhettinger for your feedback. I agree with your thought process regarding these, and have removed them. On the topic of predictability, I'm wondering if your thoughts have changed regarding this pairing. It comes up almost two hundred times in the standard library, often in deeply-nested loops. Yes, the pairing is coincidental (not conceptual). But it still seems like a cheap boost to add here. |
The reasoning about |
Thanks @rhettinger! |
This patch adds
fourone new opcode prediction:BUILD_MAP_UNPACK_WITH_CALL
->CALL_FUNCTION_EX
:**kwargs
is unpacked into a call.LOAD_BUILD_CLASS
->LOAD_CONST
:LOAD_BUILD_CLASS
->LOAD_CLOSURE
:LOAD_ASSERTION_ERROR
->RAISE_VARARGS
:assert
is used.https://bugs.python.org/issue38310