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-104635: Eliminate redundant STORE_FAST instructions in the compiler #105320

Merged
merged 2 commits into from
Jun 7, 2023

Conversation

corona10
Copy link
Member

@corona10 corona10 commented Jun 5, 2023

Benchmarks

import pyperf

runner = pyperf.Runner()
runner.timeit(name="bench dead_store",
              stmt="""
_, _, _, a = 1, 2, 3, 4
""")

Mean +- std dev: [base] 11.7 ns +- 0.2 ns -> [opt] 11.1 ns +- 0.1 ns: 1.05x faster
import pyperf

runner = pyperf.Runner()
runner.timeit(name="bench static swaps",
              stmt="""
_ = f(True, False)
""",
setup="""
def f(x, y):
    a, a = x, y
    return a
""")


Mean +- std dev: [static_base] 27.1 ns +- 0.3 ns -> [static_opt] 26.0 ns +- 0.2 ns: 1.04x faster

@corona10
Copy link
Member Author

corona10 commented Jun 5, 2023

@carljm cc @iritkatriel

Mark's change + dead_store elimination + apply_static_swaps makes 3-5% faster without adding super instruction.

('STORE_FAST', 1, 4),
('POP_TOP', 0, 4),
('RETURN_VALUE', 5)
]
Copy link
Member Author

Choose a reason for hiding this comment

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

8 instructions -> 5 instructions

('POP_TOP', 0, 4),
('STORE_FAST', 1, 4),
('RETURN_VALUE', 5)
]
Copy link
Member Author

Choose a reason for hiding this comment

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

7 instructions -> 5 instructions

@corona10
Copy link
Member Author

corona10 commented Jun 7, 2023

@carljm Can you please take a look at?

Copy link
Member

@carljm carljm left a comment

Choose a reason for hiding this comment

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

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants