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

10

3

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?

Anthony

Posted 2013-11-01T09:29:10.380

Reputation: 245

Answers

9

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

icl7126

Posted 2013-11-01T09:29:10.380

Reputation: 401

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 – 2016-09-06T04:28:55.127

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 – 2018-10-02T13:19:22.140

8

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.

Albert Gazendam

Posted 2013-11-01T09:29:10.380

Reputation: 81

Awesome answer (with sources), thanks! A couple of years late, but now I know :) – Anthony – 2017-06-01T10:38:35.483

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.

user195560

Posted 2013-11-01T09:29:10.380

Reputation: 21

4

Do you have any data to support your statements? Someone did a research http://envobi.com/post/virtualbox-hyper-threading-benchmark-surprise/ and they do recommend setting Virtual Box CPU count to the number of logical CPUs.

– Maxim Egorushkin – 2015-08-06T10:02:23.760

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.

ClaireW

Posted 2013-11-01T09:29:10.380

Reputation: 24