-
-
Notifications
You must be signed in to change notification settings - Fork 31k
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-117581: Specialize binary operators by refcount as well as type. #117627
GH-117581: Specialize binary operators by refcount as well as type. #117627
Conversation
unused/1 + | ||
_GUARD_NOS_REFCNT1 + | ||
_GUARD_TOS_IMMORTAL + | ||
_BINARY_OP_TABLE_NN; |
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.
Can you please document in the bytecodes.c
file what these suffixes mean? Some of them are easy to see, but I don't know what's NN
vs ND
immediately.
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.
Done.
Performance on both tier 1 and tier 2 is about 1% slower. |
Earlier results had an issue with the Benchmarking on tier 1 shows the slowdown to be in the noise. |
Abandoning this as #128722 is handling the same problem and we have a better ideas for reducing refcounting overhead faster-cpython/ideas#700 |
This PR changes the specialization of binary operators for the current, fairly ad-hoc approach to a bit more principled approach of specializing by refcount and using table lookup to specialize by type.
Tier 1 performance is in the noise, maybe showing a slight slowdown.
I expect the advantages of this approach to show up when applied to
BINARY_SUBSCR
,COMPARE_OP
and with the JIT.It also opens the possibility of specializing binary operators for numpy arrays and the Decimal class.