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 摘要。