python / python/cpython

Convert more uops to leave their inputs on the stack to be cleaned up by `_POP_TOP`

Open
#145,866 21 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

3.15 interpreter-core performance topic-JIT type-feature
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Feature or enhancement

Proposal:

This is a follow up to https://github.com/python/cpython/issues/134584

We have, in the JIT, optimizations to eliminate many _POP_TOP operations. To take advantage of that we have converted many uops to leave their operands on the stack and added subsequent _POP_TOPs to remove them.
See https://github.com/python/cpython/issues/134584 for many examples of how to do this and why it works.

However, there are still a few uops yet to do. These are:

  • LIST_EXTEND
  • DICT_UPDATE @Sacul0457
  • SET_UPDATE @Sacul0457
  • DICT_MERGE @NekoAsakura
  • CALL_INTRINSIC_1 @Sacul0457
  • CALL_INTRINSIC_2 @KevinH15291

In addition, POP_ITER, END_FOR and END_SEND can be implemented as macro ops, using POP_TOP to gain the benefit of the the POP_TOP optimization.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Linked PRs
  • gh-145964
  • gh-145979
  • gh-146170
  • gh-146177
  • gh-146185
  • gh-146190
  • gh-146262
  • gh-146329
  • gh-146383
  • gh-148227
  • gh-148477

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading follow-up issue 134584 for the described conversion pattern and review the listed remaining uops: LIST_EXTEND, DICT_UPDATE, SET_UPDATE, DICT_MERGE, CALL_INTRINSIC_1, and CALL_INTRINSIC_2. Also examine how POP_ITER, END_FOR, and END_SEND are represented; done means these operations use the proposed stack cleanup approach, but linked PRs show that work is already underway.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
compilers, performance
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.