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-105229: Replace some superinstructions with single instruction equivalent.#105230

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
markshannon merged 6 commits intopython:mainfromfaster-cpython:mini-super-ops
Jun 5, 2023

Conversation

@markshannon
Copy link
Member

@markshannonmarkshannon commentedJun 2, 2023
edited by bedevere-bot
Loading

Shows a surprising, but pleasing,1.7% speedup.
These are common instructions, so the reduction in code size and memory reads is considerable.

Infaster-cpython/ideas#585 I refer these to as "single instruction superinstructions", which is a rather clumsy name. I'm not sure if these need a name, but suggestions for a better name are welcome.

I've left the superinstructions involvingLOAD_CONST alone, as we are looking at other approaches to speed up constants.

@markshannonmarkshannon changed the titleReplace some superinstructions with single instruction equivalent.GH-105229: Replace some superinstructions with single instruction equivalent.Jun 2, 2023
Copy link
Member

@brandtbucherbrandtbucher left a comment

Choose a reason for hiding this comment

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

I'm not sure if these need a name, but suggestions for a better name are welcome.

"Combined instructions", maybe?

def_op('DICT_UPDATE',165)

def_op('LOAD_FAST_LOAD_FAST',168)
def_op('STORE_FAST_LOAD_FAST',169)
Copy link
Member

Choose a reason for hiding this comment

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

Just curious, how are the stats on this? Is it worth keeping?

I would expect most of these pairs to span multiple lines. Although maybe comprehensions and generator expressions make up for it?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I don't know, as you say it might be quite low.
I think we should keep it for this PR anyway, as we are replacing two-codeunit superinstructions with the one-codeunit equivalent. We can change the choice of superinstructions in another PR.

@@ -0,0 +1 @@
Replace some dynamic superinstructions will single instruction equivalents.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Replace some dynamic superinstructionswill single instruction equivalents.
Replace some dynamic superinstructionswith single instruction equivalents.

}

staticvoid
make_super_instruction(cfg_instr*inst1,cfg_instr*inst2,intsuper_op)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
make_super_instruction(cfg_instr*inst1,cfg_instr*inst2,intsuper_op)
make_combined_instruction(cfg_instr*inst1,cfg_instr*inst2,intcombined_op)

@@ -0,0 +1 @@
Replace some dynamic superinstructions will single instruction equivalents.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Replace some dynamic superinstructionswill single instruction equivalents.
Replace some dynamic superinstructionswith single instruction equivalents.

Copy link
Member

Choose a reason for hiding this comment

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

Heh. Crossed posts.

carljm reacted with hooray emoji
Comment on lines 1592 to 1594
/* Skip if instructions are on different lines */
if (inst1->i_loc.lineno!=inst2->i_loc.lineno) {
return;
Copy link
Member

Choose a reason for hiding this comment

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

I saw a comment from@brandtbucher that this requirement eliminated most super-instructions (faster-cpython/ideas#585 (comment)). And yet your pyperformance results on this PR are quite good. I wonder how these two things are both true.

Copy link
Member

Choose a reason for hiding this comment

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

For instructions without observable side effects (e.g.LOAD_FAST, or maybePOP_TOP), can't we still do a super instruction and keep theNOP for the extra lineno?

Copy link
Member

Choose a reason for hiding this comment

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

I saw a comment

Oh, I realize now that this comment was specific toSTORE_FAST__LOAD_FAST.

brandtbucher reacted with thumbs up emoji
Copy link
Member

Choose a reason for hiding this comment

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

I wonder how these two things are both true.

Oh, I guess the most likely answer is infaster-cpython/ideas#585 (comment) :

it appears that the reduction in code size more than compensates.

Copy link
MemberAuthor

@markshannonmarkshannonJun 5, 2023
edited
Loading

Choose a reason for hiding this comment

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

That is just my hypothesis.

The goal is to remove superinstructions that cross block and line boundaries, as they are problematic.
I was just trying to not slow things down by removing them. A speedup was just a pleasant surprise.
Even if the speedup is mainly from layout changes, or cache effects, the main motivation of this PR remains valid.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@carljmcarljmcarljm left review comments

@brandtbucherbrandtbucherbrandtbucher approved these changes

@brettcannonbrettcannonAwaiting requested review from brettcannonbrettcannon is a code owner

@encukouencukouAwaiting requested review from encukou

@ericsnowcurrentlyericsnowcurrentlyAwaiting requested review from ericsnowcurrentlyericsnowcurrently is a code owner

@ncoghlanncoghlanAwaiting requested review from ncoghlanncoghlan is a code owner

@warsawwarsawAwaiting requested review from warsawwarsaw is a code owner

@iritkatrieliritkatrielAwaiting requested review from iritkatrieliritkatriel is a code owner

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@markshannon@carljm@brandtbucher@bedevere-bot

[8]ページ先頭

©2009-2025 Movatter.jp