12

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?

4 Answers 4

10

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.

enter image description here

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.

enter image description here

3
  • 1
    Agreed. I was using 4 cores and found it only takes about 50% CPU time when building my project. Then in spite of the warning, I changed to 8 which is the number of the logical cores, the build was taking 100% CPU time and I believe it ran faster than before.
    – Deqing
    Commented Sep 6, 2016 at 4:28
  • This is quite interesting, I remember reading that Linux specifically tries to focus the load on 1 logical core from each physical HT core to increase efficiency. I wonder whether the guest Linux kernel gets to see that the CPU is hyper-threaded and optimize its scheduling for that type of configuration.
    – Anthony
    Commented Oct 2, 2018 at 13:19
  • 1
    this is still true in 2022. glad that i found this. Commented Mar 28, 2022 at 12:13
9

I found that even though it is possible (and arguably faster) in VirtualBox (my experience was with version 5.1.0) to allocate vCPUs to a VM based on logical processors, one may run into problems inside the guest OS when running at high load. In my case a Windows 2012 R2 VM with 12 vCPUs on a 8 core Ubuntu 16.04 host (that reports 16 logical processors) would BSOD during high CPU load with the DPC_WATCHDOG_VIOLATION error message. A minidump analysis using osronline.com showed e1g6032e.sys (the Intel 100/1000 network driver native to Windows) to be the cause of the violation.

This leads me to believe that timing inside the guest OS is negatively impacted when allocating vCPUs based on logical processor capacity and running the VM at high load for prolonged periods. In my case, 100% CPU load inside the Windows VM for a few minutes would result in the BSOD. After reducing the vCPU count to 8 (which corresponds to the physical core count of the host), the Windows VM does not BSOD anymore under similar high load situations. The online documentation from VirtualBox says one should do this, but does not offer any reasons.

In my environment there were also two other Ubuntu VMs running, each with 8 vCPUs of their own. The load on them was however minimal at the time of the Windows VM's BSOD problems.

1
  • Awesome answer (with sources), thanks! A couple of years late, but now I know :)
    – Anthony
    Commented Jun 1, 2017 at 10:38
2

Does the warning I got take into account that my machine has hyper-threading?

Yes. If you set the number of cores in a VM to greater than the number you physically have, the task scheduling process in Virtual Box over commits the CPU resources, leading to major performance issues.

As to distributing the load across cores, that is the host OS's job, and should behave in the correct manor.

1
0

Was this a VM original to your machine? Sometimes you will get peculiar errors if you clone a VM and move it to another machine and / or change settings.
I recommend downloading and installing the latest version of Virtual Box with the latest extensions.

I have committed all eight cores and I am not receiving that error with my i7 running a VM with Ubuntu 13.10.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .