python / python/cpython

Optimise keyword arguments in the JIT

オープン
#150,724 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

3.16 interpreter-core performance topic-JIT
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

Since the JIT traces can see both sides of the call, it can remove the work done to parse and shuffle the arguments during optimization.

For example, calling the function

def foo(a, b): pass

with keyword arguments:

foo(0, b=2, a=1)

requires the tuple ("b", "a") to pushed to the stack after the arguments
and for the CALL_KW_PY instruction to parse and reorder the arguments.

We can work out the reordering required and emit the necessary stack permuting code,
then replace the CALL_KW_PY with a much more effcient CALL_PY_EXACT_ARGS

In the example above:

LOAD_CONSTANT ("b", "a")
CALL_KW_PY 3

can be replaced with

SWAP 2
CALL_PY_EXACT_ARGS 3
Linked PRs
  • gh-151389

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

CALL_KW_PY と CALL_PY_EXACT_ARGS の JIT での処理から始め、issue のキーワード呼び出しの例を使って、必要な引数の並べ替えを理解してください。JIT がキーワード呼び出しをスタックを入れ替えるコードと exact-argument call に置き換え、示されている呼び出しの動作を維持できれば完了です。gh-151389 はこの作業に関連付けられています。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
compilers, performance
issue の種類
リファクタリング
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。