I have a quad-core i7 processor with hyperthreading (8 logical cores), when I configured a virtual machine to use 8 processors, VirtualBox gave me a warning saying that I only have four cores (which is true) and that this may cause a performance issue. But hyper-threading is a hardware feature, so the OS sees 8 cores and it sends instructions to all 8. What if setting it to 4 caused the VM to use 2 cores (4 threads) instead of 4 simultaneous threads (on all 4 cores)? Does the warning I got take into account that my machine has hyper-threading?
VirtualBox – How Many Processors to Configure on Quad Core Host with Hyper-Threading
cpuhyper-threadingvirtual machinevirtualbox
Related Solutions
In response to your second question:
So if I say, here Mr.VM take 1 core, will it take 1 of the 4 'cores' or 1 of 2 the physical cores?
There is an option when you create the VM and also after you have created it, in the settings panel under Processors in which you specify whether you want to use both processors, or the cores per processor.
Edit by Asker:
This proves that it does indeed take from a pool of the total cores available that includes hyper threaded cores because when I selected 8-cores it gave a warning, but when I selected 4-cores it did not.
The answer: Hyper threaded cores are included in the available cores to be given to the VM.
In my case, I don't have the ability to use that many cores or processors, but with your CPU, you should be able to do so.
Huh, I could tell you the story but you are going to hate it and I'm going to hate writing it :-)
Short version - Win10 screwed up everything it could and is in perpetual state of starving cores due to systemic problem known as cpu oversubscription (way too many threads, no one can ever service them, something is choking at any point, forever). That's why it desperately needs these fake CPU-s, shortens base scheduler timer to 1 ms and can't let you have parking anything. It would just scorch the system. Open Process Explorer and add up the number of threads, now do the math :-)
CPU Sets API was introduced to give at least some fighting chance to those who know and have the time to write the code to wrestle the beast. You can de-facto park fake CPU-s by putting them in a CPU-Set that you won't give to anyone and create default set to throw it to piranhas. But you can't do it on client sku-s (you could technically, it's just not going to be honored) since kernel would do into panic state and either totally ignore CPU Sets or some other things are going to start crashing. It has to defend system's integrity at any cost.
The whole state of affairs is by and large a tabu since it would require major rewrites and everyone culling the no of frivolous threads and admitting that they messed up. Hyperthreads actually have to be permanently disabled (they heat up cores under real load, degrade performance and destabilize HTM - the principal reason why it never became mainstream). Big SQL Server shops are doing it as a first setup step and so is Azure. Bing is not, they run servers with de-facto client setup since they'd need much more cores to dare to switch. The problem percolated into Server 2016.
SQL Server is the sole real user of CPU Sets (as usual :-), 99% of perf-advanced things in Win has always been done just for SQL Server, starting with super efficient memory mapped file handling that kills people coming from Linux since they assume different semantics).
To play with this safely you'd need 16 cores min for a client box, 32 for a server (that actually does something real :-) You have to put at least 4 cores in default set so that kernel and system services can barely breathe but that's still just a dual core laptop equivalent (you still have perpetual choking), meaning 6-8 to let the system breathe properly.
Win10 needs 4 cores and 16 GB to just barely breathe. Laptops get away with 2 cores and 2 fake "CPU-s" if there's nothing demanding to do since their usual work distribution is such that there's always enough things that have to wait anyway (long queue on memaloc "helps" a lot :-).
This is still not going to help you with OpenMP (or any automatic parallelization) unless you have a way of telling it explicitly to use your CPU Set (individual threads have to be assigned to CPU Set) and nothing else. You still need process affinity set as well, it's precondition for CPU Sets.
Server 2k8 was the last good one (yes that means Win7 as well :-). People were bulk loading a TB in 10 min with it and SQL Server. Now people brag if they can load it in one hour - under Linux :-) So chances are that the state of affairs is not much better "over there" either. Linux had CPU Sets way before Win.
Best Answer
Based on the benchmark done by Kristian Wedberg I would say you should use all logical cores you have.
Also I did my own benchmark using same CPU (i7, 4 CPU with HT) which confirmed performance boost for multi-threaded applications. If guest PC (Win. 8.1 x64) used all 8 cores, then host PC (Ubuntu x64) also used all 8 cores.
I compared also performance in single-threaded applications. In both cases I measured same values so there is no penalty using more than physical (but up to logical) number of CPUs.
Here you can see that 1 CPU full load in guest PC will result to 1 CPU load in host PC.