Fractional vCPUs and resource overcommitment

This is for discussing general topics about how to use VirtualBox.
Post Reply
falcon74
Posts: 32
Joined: 4. Jun 2018, 20:02

Fractional vCPUs and resource overcommitment

Post by falcon74 »

Interested to see if Virtualbox has any provisions for allocating fractional host cores as vCPUs for guest, i.e. 50% of a host CPU core (base-frequency of 2GHz) as a 1GHz vCPU in guest ?
This would permit 2x over-commitment, i.e. a host with say 6 physical cores and 12 threads -- rated at 2.0GHz base frequency, could be provisioned as say 20 "tiny VMs" each with max. 1GHz frequency. This still leaves 1 full physical core (2 threads @ full 2GHz) free for Virtualbox resource-management (since if 12 threads @ 2GHz -> 24 potential vCPUs @ 1 GHz max). Of course, if any of those tiny VMs runs CPU intensive workload, there is a possibility of starvation, but if there is resource management that limits usage to 1GHz equivalent of processing bandwidth, it should not be an issue for other tiny VMs.

Is such a thing possible with current Virtualbox ? If this were to be possible, I'd most likely run all of the tiny VMs "headless".

Edited:
Found this other thread (viewtopic.php?f=1&t=88864&p=426699&hili ... nt#p426699), which seems to indicate that Virtualbox doesn't support fractional host CPUs and vCPUs -- since it appears to need a 1:1 mapping of a vCPU to a full physical CPU core (perhaps not even a thread in case of hyper-threaded CPUs). Is that the correct interpretation ?

Thanks in anticipation and kind regards.
BillG
Volunteer
Posts: 5105
Joined: 19. Sep 2009, 04:44
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows 10,7 and earlier
Location: Sydney, Australia

Re: Fractional vCPUs and resource overcommitment

Post by BillG »

That is pretty much the situation as far as VirtualBox is concerned. But it is not as black or white as that. There is certainly no actual mapping of a vCPU to a particular physical CPU.

The real situation is much more complicated and varies from one host to another depending on how the host OS handles CPU queues. VirtualBox is just another application program sending requests to the host OS on behalf of its guests. The host OS does the scheduling.
Bill
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Fractional vCPUs and resource overcommitment

Post by socratis »

The CPU is one of the things (the only thing) that passes to the guest unfiltered. So if your host has an "Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz", your guest is going to see an "Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz".

On the other hand, there is the ExecutionCap (VM Settings » System » Processor » Execution Cap), but I would be very careful with that. Your guest may be making assumptions based on the CPU that's being presented with.

In all cases, I would advice you against having more vCPUs allocated to all your guests that your host has, and leave at least one core for your host to "orchestrate" the whole thing.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
falcon74
Posts: 32
Joined: 4. Jun 2018, 20:02

Re: Fractional vCPUs and resource overcommitment

Post by falcon74 »

Thanks @BillG and @socratis. Is there no way to do something like a setcpuid s.t. the CPU recognition changes (apart from the ExecutionCap setting) ?

Edit-1:
From this SuperUser Q&A I got the impression that one could set CPUID. One could for instance, be careful to pick a CPUID for a CPU (as would be visible to the guest OS) to offer a subset of the processor features of the physical host processor, and a lower base/peak frequency. Usually, for intel processor family, I think if my host processor is say a relatively higher end 8th gen i7, and I declare the guest vCPU as a low end 2nd generation i3 (or even a Core2Duo), it should be okay I suppose ?

Edit-2:
Even better, found in comments on the SU Q&A answer posted above, is a reference to a thread here on virtualbox.org forum, including a response from @socratis...
viewtopic.php?f=2&t=77211#p359428, i.e. how change the CPUID reported to guest OS.
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Fractional vCPUs and resource overcommitment

Post by socratis »

falcon74 wrote:... found ... a reference to a thread ... a response from @socratis ...
If you read carefully that thread, I'm guiding the user to delete those values, because if used inappropriately they lead to crashes. Don't start messing with the registers, unless you have a PhD in CompSci...

Plus now there's the "--cpu-profile" these days, which is much better compared to the "--cpuidset" one, much safer. But I don't think it does anything with the frequency, you should give it a shot.

What is it that you want to do and why? All that sounds too exotic/dangerous. I don't think I've gotten the gist of your thinking...
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
falcon74
Posts: 32
Joined: 4. Jun 2018, 20:02

Re: Fractional vCPUs and resource overcommitment

Post by falcon74 »

What I'd like to be able to do is run a who Kubernetes cluster on a PC for some experimentation and learning. The Kubernetes cluster that I'd like to setup, requires following type and number of VMs:
6x type-1 VMs: 2 vCPU, 2GB vRAM => 12 vCPU, 12GB vRAM
3x type-2 VMs: 2 vCPU, 4GB vRAM => 6 vCPU, 12GB vRAM
Total t.f. is 18 vCPU, 24GB vRAM.

What my PC has: 12 vCPUs @ base freq 2.8GHz (burstable to 4.0GHz), apart from 16GB vRAM. So obviously short if I'v to have 1:1 full commitment of resources.

Have seen the Kubernetes setup in server class infrastructure where the type-1 VMs were running on with CPU load of <10%, where the base-frequency of the server VM (KVM running on Xeon 2.0GHz physical processor). Which is why, I am looking for a way to define VMs on Virtualbox that could be overcommitted compared to real resources available on my PC.

Edit:
BTW, this also raises the question... is it possible to have vRAM overcommit ? Given that out of the 6 type-1 VMs, any 3 of those would ever use about max 60% of max vRAM provisioned, while other 3 would use about 20% of the max vRAM provisioned (even though all the 6 VMs are active simultaneously at a given point in time), would it be possible to have more vRAM provisioned on the VMs, although physical memory is less than the total ?
falcon74
Posts: 32
Joined: 4. Jun 2018, 20:02

Re: Fractional vCPUs and resource overcommitment

Post by falcon74 »

Found out that Virtualbox has the notion of Execution Cap for the virtual Processor, as a percentage of the physical processor's computational throughput. I did note that enabling Execution Cap (to any value other than 100%) may have a performance impact for the guestOS (or mess up the kernel timing).
Post Reply