-
-
Notifications
You must be signed in to change notification settings - Fork 32k
gh-100712: make it possible to disable specialization (for debugging) #100713
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
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.
Yup.
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.
Nice addition. I've left some minor comments.
I wonder if the changes in ceval.c
would be cleaner if we just changed the "ADAPTIVE_COUNTER" macro definitions when ENABLE_SPECIALIZATION
is zero (instead of sprinkling these #if
s everywhere). Might be about the same level of complexity, though.
@@ -304,6 +304,7 @@ dummy_func( | |||
}; | |||
|
|||
inst(BINARY_SUBSCR, (unused/4, container, sub -- res)) { | |||
#if ENABLE_SPECIALIZATION |
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.
Style nit:
Typically, we unindent #if
/#else
/#endif
one level for easier readability. I find this a bit easier to parse:
#if ENABLE_SPECIALIZATION | |
#if ENABLE_SPECIALIZATION |
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 know that's traditional, but honestly I'm not too happy with that convention and I find it less readable that what Irit proposes here. Also, she tried outdenting it in an early regmachine branch and the generated code was indentded weirdly.
@@ -276,6 +276,7 @@ static int compare_masks[] = { | |||
void | |||
_PyCode_Quicken(PyCodeObject *code) | |||
{ | |||
#if ENABLE_SPECIALIZATION |
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 think this change isn't needed unless you also want to disable superinstructions. That seems like something separate, and less useful, than what you're proposing here.
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.
IIRC it had something to do with making the interpreter easier to debug when nothing works. The more you can rule out the less code you have left to debug.
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 wonder if the changes in
ceval.c
would be cleaner if we just changed the "ADAPTIVE_COUNTER" macro definitions whenENABLE_SPECIALIZATION
is zero (instead of sprinkling these#if
s everywhere). Might be about the same level of complexity, though.
Possibly. But if we want to exclude this code from compilation we would need to rewrite ADAPTIVE_COUNTER_IS_ZERO so that it's not in an if condition.
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 think this change isn't needed unless you also want to disable superinstructions. That seems like something separate, and less useful, than what you're proposing here.
We could have a separate flat ENABLE_SUPERINSTRUCTIONS for that. We could have toggles for different kinds of optimisations, with a global one to turn them all off for debugging (the individual ones can be used to assess the performance gain of the parts, and to better document what is what):
ENABLE_BYTECODE_OPTIMIZATIONS = True
ENABLE_SPECIALIZATION = ENABLE_BYTECODE_OPTIMIZATIONS and True
ENABLE_SUPERINSTRUCTIONS = ENABLE_BYTECODE_OPTIMIZATIONS and True
ENABLE_PEEPHOLER = ENABLE_BYTECODE_OPTIMIZATIONS and True
...
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 is a feature for extreme debugging. I'd keep it as simple as possible.
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'll merge then. We can iterate on this.
Fixes #100712.