-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
GH-135379: Specialize int operations for compact ints only #135668
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-135379: Specialize int operations for compact ints only #135668
Conversation
…tion in case of overflow
Can you please add tests for the new synbol to optimizer_symbols.c? |
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.
Need tests and one comment. Otherwise LGTM.
return; | ||
case JIT_SYM_KNOWN_VALUE_TAG: | ||
if (!PyLong_CheckCompact(sym->value.value)) { | ||
Py_CLEAR(sym->value.value); |
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 don't think you need to clear things here? It's automatically cleared on finalization of the whole optimizer I think.
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.
We need to do it here (we do the same in _Py_uop_sym_set_type
) as we are changing the tag, so the finalization won't know there was an object there.
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.
AH ok that's very tricky! Good observation.
Performance is about neutral, all within noise:
Which is good, as the main point of this PR is to ultimately improve tier 2 performance as this will enable better TOS caching and easier implementation of tagged ints. |
|
This changes the way we handle ints during specialization.
Instead of handling all ints we only specialize for compact ints.
Since compact ints represent the large majority of ints we get a faster common path, at the cost of a few more de-optimizations.
Using compact ints only, and de-optimizing in the extremely rare no-memory case, we can simplify the performance critical paths for integer operations.
This is helpful for top-of-stack caching as the newer simpler instructions to not escape or need to handle errors, so avoids the need to spill to memory.
This also gives us the potential to use
BINARY_OP_EXTEND
for multi-digit ints in the future.