As I have a Hyper-Threading capable CPU, I wonder, is it a bad idea to assign more virtual CPU cores than number of physical CPU cores as the following warning suggests:
Transcript:
More virtual CPUs are assigned to the virtual machine than the number of physical CPUs on the host system. This is likely to degrade performance of your virtual machine. Please consider reducing the number of virtual CPUs.
Can someone put a reasoning to this topic?
EDIT1:
The CPU in question is Intel Core i7-4700HQ, Ark Intel, CPU Benchmark
EDIT2:
Supposing, there is no obsolete HW, like HDD (instead of an SSD), and / or Low RAM (16GB here, minimum vm.swappiness
, 4GB for this VM), and so on.
Best Answer
Hardware / OS / Software
Host: Linux Mint 18 Cinnamon 64-bit (fully updated); Kernel version 4.4.0-47-generic
Guest: Windows 8.1 Pro 64-bit (fully updated)
Processor: Intel Core i7-4700HQ, (6MB cache, 4 physical cores, or 8 using Hyper-Threading), CPU Benchmark
VirtualBox: Version 5.1.10 r112026 (Qt5.5.1)
Guest Additions: Installed and up-to-date
Benchmark Tool #1: WinRAR version 5.40 final 64-bit
Benchmark Tool #2: VeraCrypt version 1.19 final 64-bit
Preparation
In both cases I waited after boot until the CPU, RAM, disk drive are at stable near zero-point hits.
Method
Results
WinRAR
4 cores => 7.5 minutes (shorter time is better)
WinRAR with 4 cores enabled, 1.5GiB processed in 7.5 minutes.
8 cores => 4.5 minutes (shorter time is better)
WinRAR with 8 cores enabled, 1.5GiB processed in 4.5 minutes.
VeraCrypt
4 cores => speed 2.6 GiB/s (higher speed is better)
VeraCrypt with 4 cores enabled, HW-accelerated AES (AES-NI) speed 2.6 GiB/s.
8 cores => speed 3.9 GiB/s (higher speed is better)
VeraCrypt with 8 cores enabled, HW-accelerated AES (AES-NI) speed 3.9 GiB/s.
Conclusion
I could run as many tests as necessary. But I figure, if these two, one of which is rather complex compression test, the second being a set of rather complex encryption tests, what would be the point.
Both of the benchmarks show a marked difference. I see no reason to believe, that their results are inaccurate, as I followed a rather rigorous preparation and method, moreover these tests have taken place in RAM to rule out I/O bottleneck. From my standpoint, the warning mentioned in the question may apply to some conditions, but certainly not all of them. Having shared with you these pretty remarkable results, I am certain for you to agree with me, that this warning probably should not be taken so seriously on modern CPUs featuring Hyper-Threading with the latest VirtualBox version. One thing for sure: Don't take me for the word and test it under your own conditions, before you decide to apply this setting permanently.
New benchmark
Host + Guest: Linux Mint 19.2 "Tina" - Cinnamon (64-bit); both with kernel:
5.3.0-24-generic
.Processor: Intel® Core™ i7-7700HQ; 6 MB Cache, up to 3.80 GHz, 4 physical cores, or 8 using Hyper-Threading, CPU Benchmark comparison
VirtualBox: Version 6.1.0 r135406 (Qt5.9.5)
Guest Additions: Installed and up-to-date
Benchmark Tool: VeraCrypt version 1.24 Hotfix1 64-bit final (web page, direct deb download link)
Preparation and Method
Same as previous benchmark.
Results
VeraCrypt AES encryption with 4 cores
⟶ speed 4.8 GiB/s (higher speed is better)
VeraCrypt AES encryption with 8 cores (Hyper-Threading warning issued)
⟶ speed 7.2 GiB/s (higher speed is better)
Conclusion
Wonderful 50% performance increase with Hyper-Threading enabled, but only with the AES sadly, I will have to run some more comprehensive test. Will be back in a few days with results.