Quad Core host with hyper-threading, how many processors to configure in VirtualBox?

All we need is an easy explanation of the problem, so here it is.

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?

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

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

Method 2

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.

Method 3

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.

Method 4

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.

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply