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-118093: Add tier two support to several instructions #121884

Merged
merged 10 commits into from
Jul 18, 2024

Conversation

brandtbucher
Copy link
Member

@brandtbucher brandtbucher commented Jul 17, 2024

This adds tier two support to all of the the trivial instructions that our stats indicate are causing traces to end (CALL_LIST_APPEND, IMPORT_NAME, LOAD_NAME, BUILD_SET, SEND_GEN, and IMPORT_FROM). Some other, more complicated, instructions will come in their own PRs. It also turns _FOR_ITER_TIER_TWO from a deopting instruction into an exiting instruction, since we expect it to fail fairly often (since this represents normal control flow in the program).

Perf is neutral. Stats have improved, as expected (4% fewer tier one instructions, 24% fewer too-short traces, 20% fewer optimization attempts, 7% fewer traces executed, 4% more traces created, and 4% more uops executed).

@brandtbucher brandtbucher added performance Performance or resource usage skip news interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Jul 17, 2024
@brandtbucher brandtbucher self-assigned this Jul 17, 2024
Copy link
Member

@markshannon markshannon left a comment

Choose a reason for hiding this comment

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

One minor clarification needed, otherwise LGTM.

Regarding handling CALL_LIST_APPEND in tier 2:
Instead of asserting that the next instruction is POP_TOP and skipping it, we could emit a LOAD_CONST_BORROW None.
If the following instruction is not POP_TOP then then code is still correct. If there is a POP_TOP following, then optimizer will eliminate the LOAD; POP_TOP.

Python/bytecodes.c Show resolved Hide resolved
@bedevere-app
Copy link

bedevere-app bot commented Jul 17, 2024

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

@brandtbucher
Copy link
Member Author

I have made the requested changes; please review again

@bedevere-app
Copy link

bedevere-app bot commented Jul 18, 2024

Thanks for making the requested changes!

@markshannon: please review the changes made to this pull request.

@brandtbucher
Copy link
Member Author

JIT failures are unrelated: GH-121946

@brandtbucher brandtbucher merged commit 7b36b67 into python:main Jul 18, 2024
45 of 57 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) performance Performance or resource usage skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants