python / python/cpython

Optimise keyword arguments in the JIT

未关闭
#150,724 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

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. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 JIT 对 CALL_KW_PY 和 CALL_PY_EXACT_ARGS 的处理开始,使用 issue 中的关键字调用示例来理解所需的参数重排。完成的标准是 JIT 能够用执行栈置换的代码和精确参数调用替换关键字调用,同时保持所示的调用行为;gh-151389 与此工作相关联。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
compilers, performance
Issue 类型
重构
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
基本清楚
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。