python / python/cpython

Improve _Py_yield to use light weight cpu instruction

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

@corona10 已经在做这个了。

开始于 2026年2月8日。

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

描述

Proposal:

_Py_yield() currently relies on sched_yield()/SwitchToThread(), which are OS-level syscalls. We can replace these with lightweight CPU pause instructions (x86 PAUSE, AArch64 WFE, etc.) as CPython's bundled mimalloc already does in mi_atomic_yield(): https://github.com/python/cpython/blob/e682141c495c2e52368c4341ae54eea041070356/Include/internal/mimalloc/mimalloc/atomic.h#L323-L389

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs
  • gh-144587
  • gh-149784

贡献指南

打开贡献指南

从这里开始

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

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

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