python / python/cpython

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

オープン
#127,017 コメント 5 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

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. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず既存の os.cpu_count() API とプラットフォーム固有の実装を読み、次に提案で説明されている macOS の hw.perflevel0.logicalcpu sysctl を調査します。サポート対象のプラットフォーム全体で、新しい関数とキーワード引数の選択肢を比較し、関連するテストを特定します。選択した API が、サポート対象システムについて文書化された動作とカバレッジを備え、パフォーマンスコア数を確実に公開できれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
operating-systems
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。