python / python/cpython

Make size of TOS cache configurable

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

还没有人认领这个 Issue。

3.15 interpreter-core performance topic-JIT
主要语言
Python
星标
77.2k
派生
35.9k
PR 合并指标
PR 指标待抓取

描述

TOS caching was introduced by https://github.com/python/cpython/issues/135379, but it only supports a fixed number of registers.
We should make it configurable, so that we can choose the optimum number of registers for any hardware/OS combination.

Probably the simplest way to do this is to generate executor cases and stencils code for up to the overall maximum number of registers, and guard each case/function with an #if MAX_CACHED_REGISTER > N where N is the number of registers needed for that variant.
Some cases/functions will also need to guarded for when MAX_CACHED_REGISTER is too low.

For example the ideal number of output registers for _BINARY_OP variants is 3.
For machines where MAX_CACHED_REGISTER < 3, we will need to generate variants with outputs < 3, but we want to exclude those variants for machines with MAX_CACHED_REGISTER >= 3

Overall this could result in generating a lot more code, probably more than double, but if MAX_CACHED_REGISTER is unchanged then the executable size should also be unchanged.

If we increase the MAX_CACHED_REGISTER to 4 or 5 we would expect the stencils and supporting tables to increase by ~35% and ~80% respectively (growth being a bit more than linear as some instructions have N**2 variants)

Linked PRs
  • gh-145830

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先阅读 issue 135379 以及其中链接的 PR 145830 中的工作,然后跟踪此处描述的 TOS 缓存寄存器生成和 stencil 路径。完成的标准是,MAX_CACHED_REGISTER 能够为不同的硬件和 OS 组合选择合适的变体,同时在未作修改时保持所述的可执行文件大小行为不变。

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

评估

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

把新 issue 发到你的邮箱

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