9

I have an Intel Core i7 3930K with 6 CPU cores. Now, I understand that every of that cores can handle 2 separate threads. That makes 12 virtual cores - which I can see using my system monitor (see screenshot below).

But when I create a virtual machine using the VirtualBox software from Oracle, I suddenly can allocate 24 CPUs to that machine. How so?

enter image description here

So, what does that mean? Are there actually 24 cores - or is VirtualBox wrong?

And what happens if I allocate for example 4 cores - how many are really added to the virtual machine?

4 Answers 4

16

One core, with or without hyper-threading, can simulate any number of virtual cores, simply by timeslicing. However, this produces all kinds of problems because the operating systems expect that code running at the same time will actually interleave. Overprovisioning can lead to performance drops so great the system can appear frozen with operations literally taking thousands of times longer than they should.

5
  • 1
    Thanks alot, +1 you already answered my follow-up question, why my Windows 8 now always freezes! :)
    – q9f
    Commented Jan 23, 2013 at 14:54
  • 1
    The "extra" cores will be simulated (well, all of them are simulated, if you look at it that way). It works just fine. The cumulative performance will of course not be greater than that of the actual hardware. Lockups and problems are most likely bugs in the VM software that are probably fixed in newer version. I just started a 6 core VM on a 4 core HW and it works just fine, loading all 6 virtual cores (using VirtualBox 4.3.14 with Windows). VmWare also supports this. Commented Nov 15, 2014 at 19:08
  • @DavidBalažic It doesn't work "just fine". It can cause horrific performance losses. The OS will sometimes think that code is running in another core (when it actually isn't) and wait for it, using up the very resources that code would need to unblock it. It really can cause catastrophic performance losses. The OS needs to know whether a thread is running or not to behave sensibly. Commented Jun 27, 2016 at 9:37
  • @DavidSchwartz It may cause bad performance. That is 99% dependent on the VM implementation. About the OS wait you mentioned: if you mean the guest OS, then it will work fine, as the VM will "break" the "thread" that is waiting and run the other thread, irrelevant of the number of actual physical cores (vmware is more flexible here, but that again depends on the version used). Maybe you can show an actual case where the problems you mention happen. Commented Jun 27, 2016 at 20:12
  • @DavidBalažic It will not do so because it has no way to know what the thread is waiting for. It does in fact happen. OSes do in fact spin when a resource they want is held by another thread that they believe is running on a core. It really does reduce performance by factors of thousands for an OS not to know that a thread is not running. Commented Jun 27, 2016 at 21:42
1

If you allocate 4 cores you get 4 cores in the VM. However almost all the time you're better off just allocating 1 because you add a lot of overhead every time you add another core.

You can have a maximum of 5 cores in your case, if you go over that into the red area your virtual machine will become unstable.

Virtual box reccomends the maximum number of cores you use should be n-1 of your physical cores. Hyper-Threading does not count.

This thread on the virtual box forums supports this.

2
  • But why does VirtualBox tell me that even 12 cores are "ok" ? (see screenshot.) I just tried 8 and it keeps freezing...
    – q9f
    Commented Jan 23, 2013 at 15:43
  • It doesn't do this on new versions of VirtualBox by the way.
    – Tek
    Commented Aug 7, 2014 at 13:22
0

In my case, using 6 out of 8 CPUs in a 4 core 8 thread processor was faster in tests than 4 out of 8, despite VirtualBox cautioning that I may get degradation.
So I think that VirtualBox prevents one from shooting oneself in the foot if one is a newbie and will complain about slowness, while as a superuser you may dismiss this caution.

Long answer:

I have Intel-Core-i7-2820QM with 4 cores and 8 threads. I have Virtual Box 5.2.6 with Windows 10 host and guest.

Setting 6 CPUs out 8 in Virtual Box Guest settings gives next values in userbenchmark:

Multi core

MC Int 307
MC Float 326
MC Mixed 315
47% 316 Pts


Quad core

QC Int 270
QC Float 272
QC Mixed 268
61% 270 Pts

CPU-Z:

enter image description here

Setting 4 CPUs:

Userbenchmark

Multi core

MC Int 260
MC Float 269
MC Mixed 269
40% 266 Pts

Quad core

QC Int 260
QC Float 264
QC Mixed 262
59% 262 Pts

CPU-Z:

1108 4.21 6

Notes:

No thermal throttling (which happens when 100 degree Celsius) happened during test runs:

997 3.37 4

-1

The processor i7 3930K has VT-x.

Intel® Virtualization Technology (VT-x) allows one hardware platform to function as multiple “virtual” platforms. It offers improved manageability by limiting downtime and maintaining productivity by isolating computing activities into separate partitions.

That means you're able to simulate several more CPUs than the threads it can handle, thus seeing a higher number of CPUs available when using a Virtual Machine.

1
  • 2
    That’s actually not what VT-x is at all.
    – Daniel B
    Commented Jul 18, 2016 at 14:05

You must log in to answer this question.

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