JIT doesn't trace exec()-generated functions called from hot loops
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
When a hot loop calls functions generated via exec(), the loop body gets traced but the callees don't. Each callee is individually cold (called ~60 times), but the call site is hot (5,000+ calls total across different callees).
Concrete case: tinygrad generates ~5,000 pattern matching functions at startup via exec(). They're called from a tight loop:
for _, match, _ in pats:
if (ret := match(uop, ctx)) is not None: return ret
PYTHON_JIT=1 on 3.14.4 produces no improvement. The specializer works (LOAD_ATTR_SLOT fires correctly), but the JIT never compiles the callees.
Related: faster-cpython/ideas#738, #118093 (tier 2 entry at function calls).
It would be useful to either trace through exec()-generated callees at hot call sites, or detect aggregate hotness across callees sharing a call site.
Linked PRs
- gh-149575
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先,在 Python 3.14.4 上使用 PYTHON_JIT=1 重现 tinygrad 的模式匹配循环,重点关注由 exec() 生成的被调用方以及它们共享的热点调用点。将 specializer 的 LOAD_ATTR_SLOT 行为与被调用方是否被编译进行比较;当报告的热点调用工作负载显示通过生成的函数获得了 JIT 改进时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- compilers, performance
- Issue 类型
- 缺陷
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 25/100