Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
alex opened this issue Nov 19, 2024 · 5 comments
Open

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

alex opened this issue Nov 19, 2024 · 5 comments
Labels
type-feature A feature request or enhancement

Comments

@alex
Copy link
Member

alex commented Nov 19, 2024

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

@alex alex added the type-feature A feature request or enhancement label Nov 19, 2024
@nineteendo
Copy link
Contributor

Most ideas need to be discussed on Discourse: https://discuss.python.org/c/ideas/6
But that doesn't mean they'll be accepted. So, lower your expectations.

@colesbury
Copy link
Contributor

Recent Intel consumer processors (like Alder Lake) also have a hybrid architecture with performance (P-Cores) and efficiency cores (E-Cores).

I've also often wanted to scale tasks with "1 per core", such as with the Tools/ftscalingbench/ftscalingbench.py, but just knowing the number of performance cores is usually not enough. I also want to know:

  • Physical cores (i.e, ignore simultaneous multithreading / "hyperthreading")
  • NUMA nodes (i.e., CPU sockets)

@alex
Copy link
Member Author

alex commented Nov 19, 2024 via email

@terryjreedy
Copy link
Member

Perhaps os.cpu_count(details=True), where the exact details structure depends on the cpu. This would allow for processors to come.

@alex
Copy link
Member Author

alex commented Nov 19, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

4 participants