When using "-n auto", count the number of physical CPU cores instead of logical ones
See original GitHub issueI have a laptop with 6 physical CPU cores and hyper-threading. The code from auto_detect_cpus gives 12:
from os import sched_getaffinity
len(sched_getaffinity(0))
Out[24]: 12
The optimal number of parallel processes though is 6. Tests run slower when using 12 processes.
Did you consider using psutil.cpu_count(logical=False)
?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:7 (5 by maintainers)
Top Results From Across the Web
CPU Cores vs. Logical Processors & Threads - CGDirector
Logical processors are simply a measure of how many Cores the operating system sees and can address. It is, therefore, the product ( ......
Read more >Number of CPUs in Python
As such, when we count CPU cores in a system, we typically count the number of logical CPU cores, not the number of...
Read more >Setting the Number of Cores per CPU in a Virtual Machine
When you define the number of logical processors (vCPUs) for a VM, prefer the cores-per-socket configuration. Continue until the count exceeds ...
Read more >Logic Pro X 10.0.7 or later: Processing Threads setting and ...
The first setting below Automatic represents the largest number of threads Logic can create on your computer. This corresponds to the maximum ...
Read more >How to find out the number of CPUs using python
@user305883 assuming you have a x86 CPU, you have hyperthreading on this machine, i.e. each physical core corresponds to two hyperthreads ('logical' cores)....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Guys you changed something important there, now, how can we specify $(nproc) in pytest.ini or pyproject.toml ? If -n auto does not work anymore, the tests are not adapted when ran on different kind of machines 😕 If tests are IO-bounded, and not CPU-bounded, it drastically ruin testing time.
maybe a better option like “-n [auto|ncpus|ncores|{n}]” could be nice ?
Hi @AdrienPensart,
-n auto
should still be working… can you open an issue if it is not working for you?