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

Add tier 2 partial evaluation pass. #120619

Open
markshannon opened this issue Jun 17, 2024 · 3 comments
Open

Add tier 2 partial evaluation pass. #120619

markshannon opened this issue Jun 17, 2024 · 3 comments
Assignees
Labels
3.14 new features, bugs and security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) performance Performance or resource usage

Comments

@markshannon
Copy link
Member

markshannon commented Jun 17, 2024

Once an optimization pass is in place, it enables external contributors to make improvements.
It happened with the tier 1 specializer and is happening now with the tier 2 optimizer and JIT.
We should add the partial evaluation pass, so that external contributors can help with that.

The aim of the partial evaluation pass is to do computation, allocation and deallocation during optimization, so it doesn't need to be done at runtime.

We should add this pass, starting with a few very simple optimizations as placeholders for the full pass to be added later.
These optimizations should include:

  • Float unboxing
  • Temporary tuple elimination

We can start with the very simple optimization : BUILD_TUPLE 2; _RETURN_VALUE; UNPACK 2 -> _RETURN_PAIR before adding more complex optimizations in the future.

Linked PRs

@markshannon markshannon added performance Performance or resource usage interpreter-core (Objects, Python, Grammar, and Parser dirs) 3.14 new features, bugs and security fixes labels Jun 17, 2024
markshannon added a commit that referenced this issue Jun 17, 2024
* Rename _POP_FRAME to _RETURN_VALUE as it returns a value as well as popping a frame.

* Remove remaining _POP_FRAMEs
mrahtz pushed a commit to mrahtz/cpython that referenced this issue Jun 30, 2024
* Rename _POP_FRAME to _RETURN_VALUE as it returns a value as well as popping a frame.

* Remove remaining _POP_FRAMEs
noahbkim pushed a commit to hudson-trading/cpython that referenced this issue Jul 11, 2024
* Rename _POP_FRAME to _RETURN_VALUE as it returns a value as well as popping a frame.

* Remove remaining _POP_FRAMEs
@Fidget-Spinner
Copy link
Member

Fidget-Spinner commented Jul 16, 2024

@markshannon do you mind if I assign myself to this?

estyxx pushed a commit to estyxx/cpython that referenced this issue Jul 17, 2024
* Rename _POP_FRAME to _RETURN_VALUE as it returns a value as well as popping a frame.

* Remove remaining _POP_FRAMEs
@markshannon
Copy link
Member Author

This is a fairly large feature, so I'd like to do some reasonably detailed design work before we start implementing this.

Fell free to add any thoughts you have about the design here, or in https://github.com/faster-cpython/ideas, but I'd advise against starting coding just yet.

@Fidget-Spinner Fidget-Spinner self-assigned this Sep 1, 2024
@Fidget-Spinner
Copy link
Member

I propose this algorithm, starting with the simplest optimization: LOAD_FAST; POP_TOP -> _NOP, or constant propagation.
faster-cpython/ideas#561 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.14 new features, bugs and security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) performance Performance or resource usage
Projects
None yet
Development

No branches or pull requests

2 participants