Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

GH-131798: Remove JIT guards fordict,frozenset,list,set, andtuple#132289

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

Merged

Conversation

brandtbucher
Copy link
Member

@brandtbucherbrandtbucher commentedApr 8, 2025
edited by bedevere-appbot
Loading

According to thestats, this removes:

  • 144 milliontuple guards (25%)
  • 280 millionset/frozenset guards (19%)
  • 484 milliondict guards (42%)
  • 1.3 billionlist guards (34%)

It also fixes a bug that I encountered in the optimizer's logic for_UNPACK_SEQUENCE_TUPLE, which puts items on the stack inreverse order.

stonebig reacted with heart emoji
@brandtbucherbrandtbucher added performancePerformance or resource usage interpreter-core(Objects, Python, Grammar, and Parser dirs) topic-JIT labelsApr 8, 2025
@brandtbucherbrandtbucher self-assigned thisApr 8, 2025
@brandtbucher
Copy link
MemberAuthor

@Zheaoli and@tomasr8, you might be interested in checking this out. Specifically, see the changes inPython/bytecodes.c which use the same syntax asPython/optimizer_bytecodes.c, but describes theactual implementations of these instructions.

You can see that this PR breaks up the old, largerinstr definitions into smallerop definitions combined into amacro. This doesn't change the semantics of the instruction itself, but allows the JIT to remove parts of the instruction as it sees fit (in this case, separating out the type checks allows the JIT to remove them).

tomasr8 reacted with heart emoji

Copy link
Member

@Fidget-SpinnerFidget-Spinner left a comment

Choose a reason for hiding this comment

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

Just one concern.

@@ -396,7 +396,6 @@ dummy_func(void) {
op(_TO_BOOL_LIST, (value -- res)) {
int already_bool = optimize_to_bool(this_instr, ctx, value, &res);
if (!already_bool) {
sym_set_type(value, &PyList_Type);

Choose a reason for hiding this comment

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

Does CONTAIN_OP_SET and CONTAIN_OP_DICT need to remove their sym setting type as well? Or is that not even happening at the moment?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Not happening currently,._CONTAINS_OP_SET can't even set anything, since it handles bothset andfrozenset (this might be worth re-evaluating, or splitting up).

@Zheaoli
Copy link
Contributor

@Zheaoli and@tomasr8, you might be interested in checking this out. Specifically, see the changes inPython/bytecodes.c which use the same syntax asPython/optimizer_bytecodes.c, but describes theactual implementations of these instructions.

You can see that this PR breaks up the old, largerinstr definitions into smallerop definitions combined into amacro. This doesn't change the semantics of the instruction itself, but allows the JIT to remove parts of the instruction as it sees fit (in this case, separating out the type checks allows the JIT to remove them).

Thanks! I think I might need some time to understand this PR! Thanks for your patience!

brandtbucher reacted with thumbs up emoji

@brandtbucher
Copy link
MemberAuthor

Going to go ahead and merge this to reduce the risk of merge conflicts, but let me know if you have any questions@Zheaoli!

Zheaoli reacted with thumbs up emoji

@brandtbucherbrandtbucher merged commit20926c7 intopython:mainApr 9, 2025
76 checks passed
seehwan pushed a commit to seehwan/cpython that referenced this pull requestApr 16, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@Fidget-SpinnerFidget-SpinnerFidget-Spinner approved these changes

@markshannonmarkshannonAwaiting requested review from markshannonmarkshannon is a code owner

Assignees

@brandtbucherbrandtbucher

Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagetopic-JIT
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@brandtbucher@Zheaoli@Fidget-Spinner

[8]ページ先頭

©2009-2025 Movatter.jp