-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-45636: Simpler design for BINARY_OP
/INPLACE_OP
#29418
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
Conversation
Currently re-running benchmarks, for my own sanity… |
I'm glad I did. It seems that that single change contributes to the slowdown we saw on the other PR:
It's not clear to me why. Perhaps |
@brandtbucher Maybe the change created a branching point with random targets, so CPU branch predictor just gives up with prefetching. A profiler will help to find exact lines with the longest execution time. |
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.
I suspect the awkward size of nb_name_info
may be responsible for most of the slowdown.
#undef NB_NAME_INFO | ||
|
||
PyObject * | ||
_PyNumber_Op(PyObject *o1, PyObject *o2, unsigned op) |
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 just forwards to binary_op
. You might want to consider:
- Make this the function that does the work (effectively inlining
binary_op
here). - Make the old API
PyNumber_TrueDivide
, etc. call_PyNumber_Op
- Delete
binary_op
.
} | ||
|
||
PyObject * | ||
_PyNumber_InPlaceOp(PyObject *o1, PyObject *o2, unsigned op) |
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.
Same comment as for _PyNumber_Op
.
When you're done making the requested changes, leave the comment: |
See my new (preferred) approach in #29482. |
You were right @markshannon: adjusting the alignment fixes the slowdown. Nice catch.
|
Closing in favor of #29482. |
No perf impact:
https://bugs.python.org/issue45636