JIT: Set the IP and check for invalidation in `POP_TOP` only if `Py_Dealloc` is called.
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
The optimizer removes many POP_TOPs, but quite a few remain.
The code for POP_TOP looks like this:
inst(POP_TOP, (value --)) {
PyStackRef_XCLOSE(value);
}
which is fine for the interprete but in the JIT, as POP_TOP is marked as escaping, we need to set the IP before and check for invalidation afterwards.
What we could do, is have a version of POP_TOP that sets the IP and checks for invalidation only if Py_Dealloc is called, so we don't need to add SET_IP and CHECK_VALIDITY.
The new form of POP_TOP would look like this:
op(_POP_TOP_SET_IP_CHECK_INVALID, (value --)) {
if (do_decref_and_refcnt_is_zero(value)) {
SET_IP()
Py_Dealloc()
CHECK_VALID();
}
}
_POP_TOP_SET_IP_CHECK_INVALID should be inserted in the same pass that we insert _SET_IP and _CHECK_VALIDITY as we know whether we need to insert those uops, and leave POP_TOP alone in those cases.
Overall, this should speed things up as it doesn't increase the overall code size, but it does execute less code in many cases.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
POP_TOP の JIT 実装と、_SET_IP および _CHECK_VALIDITY を挿入するパスを調査します。do_decref_and_refcnt_is_zero と、既存の SET_IP、Py_Dealloc、CHECK_VALID の各パスを追跡します。完了条件は、特殊化された形式が必要な箇所にのみ挿入され、その他の箇所では POP_TOP が変更されず、無効化の動作が維持されることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- c, python
- 領域
- compilers, performance
- issue の種類
- リファクタリング
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 静か
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 48/100