VMware Communities
GenericError
Contributor
Contributor

Optimal number of CPU cores for maximizing guest performance

Hi,

I'm running Windows 10 in VMWare Fusion on Mac-Mini (2018) i7-8700B CPU @ 3.20GHz with 32GB RAM.

Thats 6 cores/12 Threads.

I have a very CPU intensive and highly parallizable workload for Windows that I want to run and get the maximum out of the CPU. I don't mind if this impacts usability of host or guest while the workload is running. I just want it to run as effective as possible.

My inclination is to set the VM to use 12 Cores so that each vCPU of the i7 is available to the guest. However, when setting up more than 6 cores, VMWare gives a warning that this may negatively impact performance on both MacOS and the Guest OS. So I'm not quite sure what to make out of this. Is this just a general warning that I am allowing Windows to eat up all the CPU cycles while running my workload? Again, that wouldn't be a problem since I am looking to fully utilize the CPU anyways.

I guess I'n not quite sure on how physical CPU cores and hyperthreading vCPUs are treated here and how the guest will be able to utilize the cores.

When I set up the VM to use all 12 Cores and start my workload with 12 threads, I can see in the MacOS ActivityMonitore that all 12 vCPUs are being fully utilized.

When I'm running the VM with 6 CPU cores and run with 12 Threads, I see only 6 CPUs fully utilized and the other 6 at 60%-75% utilization. I'm not quite certain what to make of that.

Initial test running the workload for some time show that it seems to perform better in the 12 cores setup. However, since this will still be running for a couple of days I don't wan to get into a situation where it slows down later in the process due to some problem related to using too many cores...

Thanks!

Lars

8 Replies
scott28tt
VMware Employee
VMware Employee

The host OS runs the hypervisor which runs the VM which runs the guest OS which runs your workload.

Having 12 threads is not the same as having 12 cores.

Those are the reasons for that warning.

Sounds like you’ve already found the setup which meets your objective.


-------------------------------------------------------------------------------------------------------------------------------------------------------------

Although I am a VMware employee I contribute to VMware Communities voluntarily (ie. not in any official capacity)
VMware Training & Certification blog
0 Kudos
GenericError
Contributor
Contributor

Thanks for your response, Scott...

I think what's confusing me is that I'm not quite sure what the guest OS sees and how it can use that...

The CPU has 6 actual cores and due hyperthreading, MacOS is showing them as 12 "virtual" Cores.

In the VM settings, are we configuring the number of physical or virtual cores that the VM gets to use? I suppose its the number of Virtual CPUs. The fact that the 12 vCPUs exposed by the i7 chip are actually running on 6 physical cores is probably not exposed to any part of the stack at all so it doesn't actually matter, right?

I also don't yet follow why the what you are saying would be the reason for the warning. Could you elaborate? The warning is saying that assigning more than half of the Cores to the VM might slow down both the guest and the host and I dont understand how that can be the case...

Cheers,

Lars

0 Kudos
ColoradoMarmot
Champion
Champion

So the rule of thumb is no more than N-1 virtual (vmware) cores per any individual VM, where N is the number of physical (not virtual, not hyperthreading cores in the machine), and ideally no more than N-2 (so there's always 2 for the host).

Hyperthreading is irrelevant in this case, it's physical cores - the details are somewhat arcane, but it has to do with how both the host and guest OS lock them during use.  That causes resource contention and the machine starts thrashing, slowing overall performance (and in some cases crashing).

You can run multiple N-1 virtual machines at the same time.  I have an 8-core i7 (8 real cores), and can run 2, 2-core, and 1 3-core VM's simultaneously.  The machine's slow, but it works (as long as nothing is spiking any CPU usage).  But there's a dramatic speed improvement across the board if I never exceed a total of 6 cores in use by VM's.

There are some special cases, especially on 2-core hosts.  Windows 10 and OSX both require 2 cores to the guest in order to function properly, so there will always be resource contention.  For those old machines, upgrading really is idea.  On a 4-core host, I wouldn't run more than one 2-core guest at a time if there's any significant load on the host.

0 Kudos
bluefirestorm
Champion
Champion

At a high level, each CPU core has its own L1/L2 caches and execution engine. The L1 has separate data cache and instruction cache. The execution engine is where all the actual CPU work gets done. When hyperthreading is enabled, the two hyperthreads share the L1/L2 caches and execution engine. That is why a hyperthread enabled core will not match the performance of two separate cores (e.g. 2 core/4threads CPU cannot match a 4 core/4 thread CPU).

In this situation with 12 vCPUs assigned to the VM, it is as close as it gets to have a 6 core/12 thread performance even though the Windows VM sees 12 virtual cores as the underlying hardware remains the same. While CPU virtualisation technology has vastly improved and made running VMs more efficient, there is still some unavoidable overhead of running a VM that will never be issue when compared to running Windows on the Mac mini natively.

Playing devil's advocate, if you don't have a need to access the macOS while this workload is running, why not run this workload within Windows Bootcamp natively instead of as a VM?

GenericError
Contributor
Contributor

Thanks for all your insightful replies...

Playing devil's advocate, if you don't have a need to access the macOS while this workload is running, why not run this workload within Windows Bootcamp natively instead of as a VM?

This may indeed be the way to go if push comes to shove. I'm using the system for quite a lot of different tasks at different times so having widows workloads in a VM quite convinient. But in this case, as you say... for the really CPU intensive part I might want to go straight to windows/bootcamp. Given that I should be able to boot up the bootcamp partition in VM ware as well this may make a lot of sense.

Do you happen to know whether it is possible to "clone" an existing VM to a bootcamp partition so I can take the existing system and just run it natively?

Cheers!

0 Kudos
bluefirestorm
Champion
Champion

I am not aware of a procedure to convert a Windows VM into a Bootcamp partition. I think it is best just to go with the standard Apple Bootcamp process. You might have to reactivate the Windows licence and may have to justify it to Microsoft as the licence has already been activated for the VM; I think this applies if the OS licence is Retail or OEM but maybe not for Enterprise licence. Strictly speaking OEM licence is not transferable.

0 Kudos
GenericError
Contributor
Contributor

I am not aware of a procedure to convert a Windows VM into a Bootcamp partition. I think it is best just to go with the standard Apple Bootcamp process. You might have to reactivate the Windows licence and may have to justify it to Microsoft as the licence has already been activated for the VM; I think this applies if the OS licence is Retail or OEM but maybe not for Enterprise licence. Strictly speaking OEM licence is not transferable

I was actually able to use Clonezilla. Just attach the image and physical drive to which you want to clone to the VM. Use Clonezilla to clone windows. If it is an external drive, you may need to boot the mac to recovery mode and allow booting from external media. After that, you can boot the cloned widows system like a BootCamp system. You can even bring it back in as a BootCamp VM in Fusion. (There is just some hassle with system protection that one must work around, see VMware Knowledge Base​ and I have not yet gotten the VM to boot with integrity protection re-enabled after editing the .vmdk) but in general, this seems to be working.

0 Kudos