Skip to content
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-104584: Allow optimizers to opt out of optimizing. #105244

Merged

Conversation

markshannon
Copy link
Member

@markshannon markshannon commented Jun 2, 2023

Comment on lines +164 to +165
_PyFrame_SetStackPointer(frame, stack_pointer);
return frame;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also complicate the signature of _PyOptimizer_BackEdge to signal this case back to the caller so we could avoid the stack pointer write, and the caller could just continue regular interpretation instead of needing to goto resume_frame and update interpreter state from the frame again. But probably not worth it I guess, if optimizers declining to optimize should be rare?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most calls to _PyOptimizer_BackEdge will return the same frame. We could add a check for it in JUMP_BACKWARD, but I think we would still need to save the stack pointer.
Even if we could avoid it, I suspect a single unconditional write is faster than the additional logic to avoid it.

@markshannon markshannon merged commit e8ecb9e into python:main Jun 5, 2023
22 of 23 checks passed
@markshannon markshannon deleted the allow-optimizer-to-not-optimize branch September 26, 2023 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants