virtualbox - Assigning number of Cores and Processors to a particular VM

07
2014-07
  • tulasi

    I would like to know if we could assign uneven no of cores under different processors for a particular VM. I mean say for a particular VM we decide to assign 2 Processors and a total of 3 cores, wherein one Processor gives 2 of its cores and the other a single core for processing. The question is basically to know if we use fixed CPUs or cores assigned for VMs or do we limit the maximum utilization by specifying these numbers over any available number of CPUs.

  • Answers
    Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

    Related Question

    performance - Is there an optimal setting for the number of CPU cores exposed to a VM?
  • sblair

    VirtualBox, and possibly other VM software, allows the user to specify the number of CPUs exposed to the VM. In my particular case, I have a dual core CPU, with Windows 7 64-bit running natively, and Ubuntu 9.04 64-bit as the VM.

    The help file suggests not setting this above the number of physical cores available. This makes sense. So, is it best allocating 1 or 2 CPU cores? Does this depend entirely on the native CPU load?


  • Related Answers
  • Nate

    It entirely depends on what the guest OS is doing. In my personal experience a VM is running a single program (build server, trac server, SVN, etc) so there is no reason to set it above one.

    A possible case may be if it's an end user on say a University that is using the guest OS as a throwaway (i.e. TAs) then maybe set it to higher than one.

  • Mark Henderson

    You should never assign all your cores as vCPUs in a virtual machine.

    If a VM requests any CPU time, VMWare has to allocate either all the vCPUs, or none of the vCPUs.

    What this means is, on a 4-core system if you allocate all 4 cores, then only either the host, or the guest, can be allocated processor time, not both at the same time.

    This will absolutally ruin performance in both environments.

    Feel free to allocate an odd-number of cores (say, 3). It feels odd, but it's a totally legitimate option.

    Generally I never allocate more than (n/2) vCPUs (in your case, 2) - but I'm normally allocating cores on servers with between 12 and 32 cores where you can allocate huge numbers of vCPUs without major impact.

  • Breakthrough

    The number of cores exposed to guest CPUs does not affect performance as much as you would like. It merely adjusts the amount of cores the guest CPU "sees".

    Depending on how the emulator is set up, it could literally half the performance of the virtual machine, do nothing, or only impact the way the guest OS/applications split up their thread scheduling.

    It's best to leave it to the default. If you encounter performance issues on the host PC, then you can simply adjust the process priority with the Windows Task Manager.

  • Andrew Coleson

    I'd trust the OS's scheduler and just set the VM to the # of physical cores, unless you Know that you always want the host to have a potentially idle core while you're busy in the VM.

  • DragonLord

    This depends on what you want to do on the virtual machine as well as on the physical machine. If you need to use the virtual machine while the host operating system is being used for some other activity, it may be better to use two processor cores for the VM so that the host has two remaining if the VM is under full load. On the other hand, if you are working primarily on the VM, you can use all processor cores.

    However, unless the guest can be expected to use all four cores at once, you can safely use all of them while continuing to work on the host OS. Remember that you can always adjust the priority of the VM process while it's running on the host operating system, and the system will balance the loads accordingly.

  • Joel Martinez

    yes, I'd also say that it depends. But I'll say what I prefer to do. At work I have a quad core CPU. So for my virtual image (win7), I've allocated two CPUs. That way, I can use both the host machine and the virtual machine at the same time, and they each have equal CPU resources.