How does VB handle Hyperthreading?

This is for discussing general topics about how to use VirtualBox.
ToddAndMargo
Posts: 306
Joined: 6. Aug 2007, 02:24

How does VB handle Hyperthreading?

Post by ToddAndMargo »

Hi All,

How does Virtual Box handle multiple hyperthreaded cores?

I have an x5650 processor with 6 real cores that presents itself to my OS as 12 virtual cores (hyperthreading). Hyperthreading can not be turned off in the BIOS.

Does Virtual Box see 6 or 12 cores?

My big concern here is that if I tell Virtual Box to use 4 cores on my x5650, will I get 4 hyperthreaded cores for a total of 2 actual/real cores?

Or if I ask for four cores, will I actually get four actual/real cores?

Many thanks,
-T
Sasquatch
Volunteer
Posts: 17798
Joined: 17. Mar 2008, 13:41
Primary OS: Debian other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows XP, Windows 7, Linux
Location: /dev/random

Re: How does VB handle Hyperthreading?

Post by Sasquatch »

VB handles the cores by asking the Host OS for it. The Host then allocates the resources. If you read more about Hyperthreading, you will know what it does and what it means.
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org

Retired from this Forum since OSSO introduction.
ToddAndMargo
Posts: 306
Joined: 6. Aug 2007, 02:24

Re: How does VB handle Hyperthreading?

Post by ToddAndMargo »

Sasquatch wrote:VB handles the cores by asking the Host OS for it. The Host then allocates the resources. If you read more about Hyperthreading, you will know what it does and what it means.
And I have no idea what you just said. :'[
kebabbert
Volunteer
Posts: 321
Joined: 31. May 2008, 10:00
Primary OS: OpenSolaris 11
VBox Version: OSE other
Guest OSses: WinXP, RedHat, Ubuntu

Re: How does VB handle Hyperthreading?

Post by kebabbert »

Then maybe you should not concern about hyper threading? ;)

It seems that VirtualBox asks the hardware about cores. Read the manual?
ToddAndMargo
Posts: 306
Joined: 6. Aug 2007, 02:24

Re: How does VB handle Hyperthreading?

Post by ToddAndMargo »

kebabbert wrote:It seems that VirtualBox asks the hardware about cores.

And does VirtualBox get told 6 or 12 cores?

Does VirtualBox even know the difference?
Read the manual?
Not in the manual.

To re-ask my question: if I tell Virtual Box to use 4 cores on my x5650, will I get 4 hyperthreaded cores for a total of 2 actual/real cores? Or if I ask for four cores, will I actually get four actual/real cores?
fixedwheel
Volunteer
Posts: 1699
Joined: 13. Sep 2008, 02:18

Re: How does VB handle Hyperthreading?

Post by fixedwheel »

ToddAndMargo wrote:if I tell Virtual Box to use 4 cores on my x5650, will I get 4 hyperthreaded cores
yes
... for a total of 2 actual/real cores? Or if I ask for four cores, will I actually get four actual/real cores?
no, you can not tell, its handled by the host OS like that: VBox starts another quite ordinary process for each additional virtual CPU you assign
Sasquatch
Volunteer
Posts: 17798
Joined: 17. Mar 2008, 13:41
Primary OS: Debian other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows XP, Windows 7, Linux
Location: /dev/random

Re: How does VB handle Hyperthreading?

Post by Sasquatch »

fixedwheel wrote:
ToddAndMargo wrote:if I tell Virtual Box to use 4 cores on my x5650, will I get 4 hyperthreaded cores
yes
Actually, no. You don't get hyperthreaded cores. You get separate cores. If you assign 2 cores to VB and it happens to be one physical core split in two due to the hyperthreading, then so be it.
If you would get a hyperthreaded core, you would get on the Guest what you have on the Host. One physical cores with two virtual ones. Not the case with VB.

Of course, if that was the question, then yes is the correct answer ;).
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org

Retired from this Forum since OSSO introduction.
ToddAndMargo
Posts: 306
Joined: 6. Aug 2007, 02:24

Re: How does VB handle Hyperthreading?

Post by ToddAndMargo »

fixedwheel wrote:
ToddAndMargo wrote:if I tell Virtual Box to use 4 cores on my x5650, will I get 4 hyperthreaded cores
yes
... for a total of 2 actual/real cores? Or if I ask for four cores, will I actually get four actual/real cores?
no, you can not tell, its handled by the host OS like that: VBox starts another quite ordinary process for each additional virtual CPU you assign
By any chance, are the guest's core not actually linked to the physical cores on the host? Rather, are they made up (fake) cores like everything else on the guest (video, network, hard drive, PCI controllers, etc.)?

In which case, does a guest core just correspond to a "Program" (or "processes" if you wish) on the host? Also in which case, can you have any number of "fake" cores on the guest as long as the host has the chops to handle it? And are the "fake" cores just single cores emulating a core with only one pipe (not two, like hyperthreading)?

If so, with 6 real cores and 12 hyperthreaded cores on my motherboard (hyperthreading can not be turned off in BIOS), how many cores would you assign to the guest? 4 or 10? (Must be an even number of cores or M$ programs like M$SQL will lay an egg.)

Is there a "best practice" rule to follow when assigning hyperthreaded cores to a guest?

Sorry for being so thick headed here. I will get this eventually.

Many thanks,
-T
ToddAndMargo
Posts: 306
Joined: 6. Aug 2007, 02:24

Re: How does VB handle Hyperthreading?

Post by ToddAndMargo »

Sasquatch wrote:
fixedwheel wrote:
ToddAndMargo wrote:if I tell Virtual Box to use 4 cores on my x5650, will I get 4 hyperthreaded cores
yes
Actually, no. You don't get hyperthreaded cores. You get separate cores. If you assign 2 cores to VB and it happens to be one physical core split in two due to the hyperthreading, then so be it.
If you would get a hyperthreaded core, you would get on the Guest what you have on the Host. One physical cores with two virtual ones. Not the case with VB.

Of course, if that was the question, then yes is the correct answer ;).
Sasquatch,

I still have no idea what you are saying. It is embarrassing! Would you please lower the technical level a notch so that a beginner can grasp what you are saying? (Tie half your brain behind your back.)

Is the guest seeing an actual core or just a fake process emulating a core?

Many thanks,
-T
Sasquatch
Volunteer
Posts: 17798
Joined: 17. Mar 2008, 13:41
Primary OS: Debian other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows XP, Windows 7, Linux
Location: /dev/random

Re: How does VB handle Hyperthreading?

Post by Sasquatch »

The Guest gets a real core, but the Host decides which it gets. The load gets balanced between all the cores, so it can run on core 1 for two seconds, and then run on core 3 a second later. The load is distributed over the HT pipes too, so you don't always get the first pipe to the core, sometimes you get the second. But I've yet to see a VM getting both pipes to just one core when it's set to have 2 cores. I think that is impossible due to the nature of how HT works, but I've been proven wrong on more than one occasion.

I do have a bad habit of writing things down the way I see them, which makes no sense at all for others. Makes it hard to see what is hard to understand. I hope I made sense to you with this post.
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org

Retired from this Forum since OSSO introduction.
ToddAndMargo
Posts: 306
Joined: 6. Aug 2007, 02:24

Re: How does VB handle Hyperthreading?

Post by ToddAndMargo »

Sasquatch wrote:The Guest gets a real core, but the Host decides which it gets. The load gets balanced between all the cores, so it can run on core 1 for two seconds, and then run on core 3 a second later. The load is distributed over the HT pipes too, so you don't always get the first pipe to the core, sometimes you get the second. But I've yet to see a VM getting both pipes to just one core when it's set to have 2 cores. I think that is impossible due to the nature of how HT works, but I've been proven wrong on more than one occasion.
Okay, so the guest is just another program to the host. And, the host OS does the load balancing.

Do you have a rule of thumb as to how many core to assign to a guest? For instance, with an Intel x5650 with 6 real and 12 hyperthreaded cores, how many cores would you assign to the guest?

Many thanks,
-T

I do have a bad habit of writing things down the way I see them, which makes no sense at all for others. Makes it hard to see what is hard to understand. I hope I made sense to you with this post.
No problem. You are doing fine. I am thicker than cement on this question.
crash0veride
Posts: 43
Joined: 23. Apr 2009, 22:29
Primary OS: Linux other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: WinXP, Win 7, Windows Server 2008 R2, SL 6, OEL 6, FC 15
Location: ThE MaTriX

Re: How does VB handle Hyperthreading?

Post by crash0veride »

See My thread on Intel SMT and VBox:
Intel SMT
Sasquatch
Volunteer
Posts: 17798
Joined: 17. Mar 2008, 13:41
Primary OS: Debian other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows XP, Windows 7, Linux
Location: /dev/random

Re: How does VB handle Hyperthreading?

Post by Sasquatch »

Basic rule for core assignment is to leave one for the Host so that VMs can never lock up the host. So with a hexacore CPU, it would be 5 cores tops.
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org

Retired from this Forum since OSSO introduction.
ToddAndMargo
Posts: 306
Joined: 6. Aug 2007, 02:24

Re: How does VB handle Hyperthreading?

Post by ToddAndMargo »

Sasquatch wrote:Basic rule for core assignment is to leave one for the Host so that VMs can never lock up the host. So with a hexacore CPU, it would be 5 cores tops.
Thank you!

So, just ignore the hyperthread. Also, use an even number of multiple cores, if you are using any M$ software on the guest that freaks out over odd numbers of processors, such as MSQL server

-T
Sasquatch
Volunteer
Posts: 17798
Joined: 17. Mar 2008, 13:41
Primary OS: Debian other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows XP, Windows 7, Linux
Location: /dev/random

Re: How does VB handle Hyperthreading?

Post by Sasquatch »

The assignment of cores also counts for the amount of VMs you can safely start without having to worry about a possible compromise of the Host resources. With 5 cores at your disposal, you can start 5 VMs with single core or 2 VMs with 2 cores and 1 with 1 core, etc.
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org

Retired from this Forum since OSSO introduction.
Post Reply