Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
GH-125837: Rework the instructions for loading constants and returning values.#125878
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Performance impactwithout the JIT is in the noise. Nominally 0.2% slower Performance impactwith the JIT is also in the noise. Nominally 0.2% faster. Stats shows that almost 90% of My hypothesis is that the slowdown caused by extra dispatching is mostly offset by the more efficient |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
Uh oh!
There was an error while loading.Please reload this page.
| _PyInterpreterFrame*dying=frame; | ||
| frame=tstate->current_frame=dying->previous; | ||
| _PyEval_FrameClearAndPop(tstate,dying); | ||
| _PyEval_ClearGenFrame(tstate,dying); |
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.
Is the only difference betweenRETURN_VALUE_FUNC andRETURN_VALUE_GEN the call to_PyEval_ClearThreadFrame vs_PyEval_ClearGenFrame? Couldn't_PyEval_FrameClearAndPop just switch on whether or notframe->owner == FRAME_OWNED_BY_GENERATOR?
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.
That's exact what it used to do.
We generally want to make decisions at compile time if we can.
It's the second bullet in#125837 (comment)
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 generally want to make decisions at compile time if we can.
We also made some efforts to reduce the number of bytecodes and the size of the eval loop implementation.
And copy-pasting 20 lines of code to change one is... controversial.
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.
And copy-pasting 20 lines of code to change one is... controversial.
It's 16 lines, but I see your point.
Doing this gives more flexibility to refactor and optimize the two return paths separately.
Both_PyEval_ClearGenFrame and_PyEval_ClearThreadFrame call_PyFrame_ClearExceptCode() but have to do
different things around that call.
For example, we could end up with something like this:
macro(RETURN_VALUE_FUNC)=_CLEAR_FRAME+_POP_THREAD_FRAME+_RETURN_VALUE;macro(RETURN_VALUE_GEN)=_GEN_POP_EXC_STATE+_CLEAR_FRAME+_RETURN_VALUE;
but not in this PR.
| } | ||
| staticbool | ||
| all_exits_have_lineno(basicblock*entryblock) { |
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.
Could you comment out rather than delete?
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'd rather delete it, otherwise it just rots.
We do have version control, if you need it back.
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.
Could you comment out rather than delete?
If it doesn't get deleted, compiler may raise warnings, see325c5fe:‘all_exits_have_lineno’ defined but not used [-Wunused-function]
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.
If it doesn't get deleted, compiler may raise warnings
But not if it's commented out.
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.
dis doc needs updating.
When you're done making the requested changes, leave the comment: |
The magic comment is "I have made the requested changes; please review again". |
Thanks for making the requested changes! @iritkatriel: please review the changes made to this pull request. |
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 have reservation about introducing yet more code duplication, but I understand you are adamant this is a good idea.
I'm closing this for now. We can revisit splitting up #125972 splits up |
Uh oh!
There was an error while loading.Please reload this page.
Adds:
RETURN_VALUE_FUNCRETURN_VALUE_GENINSTRUMENTED_RETURN_VALUE_FUNCINSTRUMENTED_RETURN_VALUE_GENLOAD_CONST_IMMORTALRemoves:
RETURN_VALUERETURN_CONSTINSTRUMENTED_RETURN_VALUEINSTRUMENTED_RETURN_CONSTRETURN_VALUEandRETURN_CONST#125837