Assigning all cores to VM

Here you can provide suggestions on how to improve the product, website, etc.
Post Reply
granada29
Volunteer
Posts: 702
Joined: 3. Mar 2015, 07:27
Primary OS: Mac OS X other
VBox Version: OSE other
Guest OSses: Linux, macOS, Windows

Assigning all cores to VM

Post by granada29 »

It's common wisdom with VirtualBox on Macs that you should NOT assign all the physical cores to a VM.

I have found that it is in fact possible to assign all the cores, without detriment to the other processes running on the Mac, if you use a program such as CPUSetter (https://www.whatroute.net/cpusetter.html) to limit the maximum CPU usage of the VM when it is running in the background.

Typically I assign 4 (i.e. all the cores) on my iMac 5K to the VM
Use CPUSetter to limit the VirtualBoxVM process to 300%
Optionally use CPUSetter to set the 'nice' priority of VirtualBoxVM to -1.

When you bring the VM into the foreground (i.e. you are using it) the 300% limit is dropped and it will use all 4 cores if required.

Perhaps VirtualBox itself employs a similar strategy and this is unnecesary, but I haven't seen evidence of that.
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: Assigning all cores to VM

Post by socratis »

granada29 wrote:It's common wisdom with VirtualBox on Macs that you should NOT assign all the physical cores to a VM.
It's common wisdom with VirtualBox on any host that you should NOT assign all the physical cores to a VM.

There, I fixed it for you ;)
granada29 wrote:Perhaps VirtualBox itself employs a similar strategy and this is unnecesary, but I haven't seen evidence of that.
Have you seen the CPU Execution cap under VM Settings » System » Processor? And there's also the built-in "nice" for Linux/OSX/Solaris hosts? And the Priority for Windows?

But if you find it useful, by all means use it. I've seen the author's work, in both the old WhatRoute (an old time really favorite in the Classic Mac days), as well as VBoxRawdisk, which is also featured in these forums! See: VBoxRawdisk - macOS utility to generate rawdisk VMDKs, in the Third Party Applications area.

Now, back to the basics, the fundamental question of your post...
granada29 wrote:I have found that it is in fact possible to assign all the cores, without detriment to the other processes running
Don't generalize. There are processes that can benefit, and processes that can bring down the host. Seriously, I've had it happen. There's no one-size-fits-all, that's why there are options.

One thing is for certain; if you certainly want to avoid potential problems, always use one less core than your host has. In certain cases, yes, you could get away with assigning the same number of cores in your VM as your host, such as no I/O or networking, simply number crunching. If you assign more, you're looking for trouble, and it will most certainly raise a big red flag, and it's the first thing that anyone that looks at your log will tell you to address.

For some additional information, take a look at "CPU Cores versus threads" and "Why is it a bad idea to allocate as many VCPUs as there are physical CPUs?".

Since you're ending your post with a suggestion, moving this to "Suggestions" from "OSX Hosts".
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.
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: Assigning all cores to VM

Post by michaln »

granada29 wrote:It's common wisdom with VirtualBox on Macs that you should NOT assign all the physical cores to a VM.
It's like this. Either you don't fully load all the cores in the VM, in which case you don't need them. Or you do fully load them, and in that case you will starve the host, causing horrible virtualization performance and possibly failures/errors. But if you'd rather not keep things simple and use complicated tweaks that work for you, no one can stop you.
Post Reply