question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When using "-n auto", count the number of physical CPU cores instead of logical ones

See original GitHub issue

I 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:closed
  • Created 3 years ago
  • Reactions:5
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
AdrienPensartcommented, Aug 18, 2020

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 ?

0reactions
nicoddemuscommented, Aug 19, 2020

Hi @AdrienPensart,

If -n auto does not work anymore, the tests are not adapted when ran on different kind of machines 😕

-n auto should still be working… can you open an issue if it is not working for you?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found