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

cpu_count is inconsistent between proc count and cpu count #614

Closed
wants to merge 3 commits into from
Closed

cpu_count is inconsistent between proc count and cpu count #614

wants to merge 3 commits into from

Conversation

johnburnett
Copy link

cpu_count() seems to return inconsistent results between platforms. I think it comes down to an assumption on whether logical=False means "physical cpus" or "physical cores". On Windows, it looks like it returns the core count, while Linux returns the cpu count.

In my case, I was assuming the former (cores), and that's the actual useful value I'm needing (in this case, I want to run something on N-1 cores, leaving one full core for the user). However, on Linux, with a dual-proc X5550, I'm getting 2 for logical=False, and 16 for logical=True. Launching 15 threads swamps the machine, and 2 is obviously not great :). It works as expected on Windows (logical=False gives 8).

I have a patch for _pslinux.py:cpu_count_physical to make it behave the way I expected, but I wanted to check if all of the above sounds right? I also haven't looked at any other platform beyond Linux and Windows, and what is happening there.

@johnburnett
Copy link
Author

Ping on this? (just got around to fixing the python 3 ci break related to this...)

@giovtorres
Copy link

Confirmed this PR fixes the same bug I found. The current cpu_count_physical() returns number of sockets, not number of physical cores.

@giampaolo giampaolo closed this in 97fd107 Jun 3, 2015
@giampaolo
Copy link
Owner

I've just fixed this with a variant of your patch. Please confirm this works as expected.

@giovtorres
Copy link

Works. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants