python / python/cpython

Add an API to allow getting the number of "performance" cores-only

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

还没有人认领这个 Issue。

type-feature
主要语言
Python
星标
77.2k
派生
35.9k
PR 合并指标
PR 指标待抓取

描述

Feature or enhancement

Proposal:

Currently Python provides os.cpu_count() which returns the total number of physical CPU cores.

On macOS M-class machines (and probably other ARM hardware), there are actually two types of CPU cores: performance cores, and efficiency cores.

For many tasks where a user wants to do "1 task per core", it really only makes sense to do 1 task per performance core.

Therefore it'd be sensible to expose this number. On macOS it can be found with the hw.perflevel0.logicalcpu sysctl.

This could be done in one of two ways, a new function, e.g. os.performance_cpu_count(), or as a keyword-argument to os.cpu_count(performance_cores_only=True).

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

贡献指南

打开贡献指南

从这里开始

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

调研方向

首先阅读现有的 os.cpu_count() API 及其特定于平台的实现,然后调查提案中描述的 macOS hw.perflevel0.logicalcpu sysctl。比较在受支持平台上采用新函数和关键字参数的方案,并找出相关测试。当所选 API 能够可靠地提供性能核心数量,并且针对受支持系统具有文档化的行为和测试覆盖时,即视为完成。

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

评估

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

把新 issue 发到你的邮箱

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