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

use psutil.cpu_affinity() instead of os.cpu_count() #17409

Merged
merged 3 commits into from
Jan 31, 2024

Conversation

altendky
Copy link
Contributor

@altendky altendky commented Jan 26, 2024

Purpose:

Hand off handling of various cases to psutil. Similar to #6131.

https://psutil.readthedocs.io/en/latest/#psutil.cpu_count

Note that psutil.cpu_count() may not necessarily be equivalent to the actual number of CPUs the current process can use. That can vary in case process CPU affinity has been changed, Linux cgroups are being used or (in case of Windows) on systems using processor groups or having more than 64 CPUs. The number of usable CPUs can be obtained with:

>>> len(psutil.Process().cpu_affinity())
1

Current Behavior:

New Behavior:

Testing Notes:

@altendky altendky added the Changed Required label for PR that categorizes merge commit message as "Changed" for changelog label Jan 26, 2024
@altendky altendky requested a review from a team as a code owner January 26, 2024 13:24
Copy link
Contributor

File Coverage Missing Lines
chia/plotting/check_plots.py 0.0% lines 29, 60
chia/util/beta_metrics.py 50.0% lines 27
Total Missing Coverage
18 lines 3 lines 83%

@emlowe
Copy link
Contributor

emlowe commented Jan 31, 2024

coverage diff exemption

@Starttoaster Starttoaster merged commit 6fe2c9c into main Jan 31, 2024
265 of 266 checks passed
@Starttoaster Starttoaster deleted the use_psutil_cpu_affinity branch January 31, 2024 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changed Required label for PR that categorizes merge commit message as "Changed" for changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants