Pin vcpu core to the physicl cpu core

Discussions related to using VirtualBox on Linux hosts.
Post Reply
frankkong
Posts: 2
Joined: 17. Apr 2017, 22:34

Pin vcpu core to the physicl cpu core

Post by frankkong »

Hello,

Is it possible to pin virtualbox vcpu core to physical ones? For example, pin vcore 1 to physical cpu core 1 in host.

If it's possible, how to do that?

Thanks,
Jian
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Pin vcpu core to the physicl cpu core

Post by Perryg »

Not really and you should not do this anyway. The host can better use the resources as well as the guest if it is not restricted. Just don't give more than 50% of the available cores to the guest and you should have optimal usage.
frankkong
Posts: 2
Joined: 17. Apr 2017, 22:34

Re: Pin vcpu core to the physicl cpu core

Post by frankkong »

Actually, I run docker containers in virtualbox, and I need to pin one container process to one physical core to guarantee the container's performance. I can pin the container process to the vcpu core. Without the vcpu core pin to the physical core, it seems impossible for my container solution.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Pin vcpu core to the physicl cpu core

Post by Perryg »

I don't use docker but if that is they way they want to secure performance I would wonder why. Anyway nothing that VirtualBox can do. You should look at the host OS for any other way, but I would really like to see the rational behind it with modern day processors.
bobpaul
Posts: 15
Joined: 19. Dec 2007, 08:30
Primary OS: Ubuntu other
VBox Version: PUEL
Guest OSses: Windows, Linux, Other

Re: Pin vcpu core to the physicl cpu core

Post by bobpaul »

Perryg wrote:but I would really like to see the rational behind it with modern day processors.
Remote memory (each socket has its own bank of ram) and cache misses (each core has its own cache, though it shares some caches with other cores on the socket). If the OS is moving a VM's threads around then the likelihood of cache misses and slow remote memory lookups increases. Especially in situations where the host is overprovisioned, one might want to have a couple of important VMs pinned to their own cores.

Guest vcpu -> host cpu affinity is offered in some fashion by FreeBSD's bhyve, Linux's kvm and xen, as well as the big proprietary VM softWare products.

This isn't a feature I use, but it does look like VirtualBox in the minority without it.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Pin vcpu core to the physicl cpu core

Post by mpack »

bobpaul wrote:but it does look like VirtualBox in the minority without it.
Always a deeply unimpressive argument that one, I've felt, and I suspect the devs will feel the same way. Show them why lots of moola is sure to come their way when they implement this feature, then they'll be impressed.
michaln
Oracle Corporation
Posts: 2973
Joined: 19. Dec 2007, 15:45
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: Any and all
Contact:

Re: Pin vcpu core to the physicl cpu core

Post by michaln »

frankkong wrote:I need to pin one container process to one physical core to guarantee the container's performance.
No. If you need to truly guarantee the container's performance, you need to not run it in a VM.
Post Reply