python / python/cpython

Calls across stack chunks perform badly

未关闭
#142,183 11 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

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

描述

The Python stack is composed of a series of chunks of memory. These chunks are large, so we cross the boundaries infrequently and assume that it will never be on the fast path.

Unfortunately, it is possible to cross the boundary repeatedly if looping deep in the stack.

We should adjust the stack when crossing the boundary, to avoid doing so repeatedly.

Possible options include:

  1. Move the caller to the new chunk, so repeated calls do not cross the boundary.
  2. Instead of using a chunked stack, double the size of the stack and copy the old stack.

Both of these assume that we can move the frame. This is only possible if there are no pointers into the frame.
If a frames calls a native function taking an array of arguments, then there will be pointers into the frame.
So if we do any moving, we need to check for these pointers.

While we cannot move the frame, we can copy it, as long as the original remains. This is a bit wasteful, but shouldn't happen too often or waste too much space.

Linked PRs
  • gh-145789
  • gh-145828
  • gh-145829
  • gh-146123
  • gh-148681
  • gh-149097

贡献指南

打开贡献指南

从这里开始

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

调研方向

首先查看链接的 PR gh-145789、gh-145828、gh-145829、gh-146123、gh-148681 和 gh-149097,因为该 issue 没有提供文件或测试。当能够避免 stack chunk 之间的重复切换,同时在 native calls 持有指向 frames 的指针时保持正确性时,即视为完成。

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

评估

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

把新 issue 发到你的邮箱

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