python / python/cpython

_CHECK_FUNCTION interferes with partial evaluation

未關閉
#126,902 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

interpreter-core type-feature
主要語言
Python
星號
77.2k
分支
35.9k
PR 合併指標
PR 指標待擷取

描述

Feature or enhancement

Proposal:

A reminder of how _CHECK_FUNCTION looks like:

        tier2 op(_CHECK_FUNCTION, (func_version/2 -- )) {
            assert(PyStackRef_FunctionCheck(frame->f_funcobj));
            PyFunctionObject *func = (PyFunctionObject *)PyStackRef_AsPyObjectBorrow(frame->f_funcobj);
            DEOPT_IF(func->func_version != func_version);
        }

frame->f_funcobj becomes invalid once we start inlining functions. Thus we should "burn in" the function object version to be checked whenever possible, to not interfere with inlining and partial evaluation.

An added benefit is that the "burned in" version is also cheaper as it doesn't have to read from the frame struct, rather reading from the instruction itself in the JIT.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs
  • gh-126856

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從 issue 中所示的 _CHECK_FUNCTION tier2 操作開始,檢查函式被內嵌時如何使用 frame->f_funcobj。查看關聯的 PR gh-126856,並判斷是否可以將函式版本固化到指令中,而不干擾部分求值;完成的標準是,在可行的情況下,版本檢查不再依賴已失效的 frame 參照。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
c, python
領域
backend, compilers, performance
Issue 類型
功能
難度
5/5
預估耗時
一週以上
活躍度
停滯
描述清晰度
基本清楚
新手友好度
25/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。