utmapp / UTM

Virtual machines for iOS and macOS
https://getutm.app
Apache License 2.0
26.94k stars 1.34k forks source link

Improve speed for x86 Windows guest by enabling Hyper-V Enlightenments by default #4914

Open stonerl opened 1 year ago

stonerl commented 1 year ago

Currently, with the default settings for Windows guests on x86 hardware, the guests are very sluggish. To improve speed and the overall responsiveness, the following settings should be applied by default.

  1. Disable HPET support -no-hpet[1]
  2. Set the following Hyper-V Enlightenments [2] by default: hv-relaxed,hv-vapic,hv_spinlocks=0x1fff,hv-runtime,hv-time,hv-frequencies,hv-xmm-input

This increases speed (~20 % in single core & ~11 % in multicore) [3] and responsiveness of the VM dramatically. I tested this with Geekbench 5 (Windows 11 guest):

Bare Metal: 1241/4766 Default settings: 848/3022 With Hyper-V Enlightenments: 1017/3375

[1] i386 target only [2] Hyper-V Enlightenments [3] Comparison between default settings and Hyper-V Enlightenments

osy commented 1 year ago

This works only on Intel with HVF I presume?

stonerl commented 1 year ago

This works only on Intel with HVF I presume?

I guess (I used it with HVF on Intel) , from what I read in the documentation. If someone with an Apple Silicon Mac could test whether these Enlightenments are also exposed there, for x86 guests, would be appreciated. Since I don't own such a device I can't test this myself.

What is the standard Hypervisor an Apple Silicon for x86? TCG or HVF?

osy commented 1 year ago

HVF uses hypervisor. TCG is an emulator and recompiles the code so I doubt it works here.

stonerl commented 1 year ago

Sorry, I expressed myself incorrectly. I'm aware that TCG doesn't use the Hypervisor. What I meant to say was, whether HVF can be used on Apple Silicon for x86 guests or if TCG has to be used.

But after reading the QEMU documentation again it seems that the Enlightenments are only available on x86 hosts for x86 guests.

osy commented 1 year ago

@stonerl Are you sure Hyper-V enlightenments actually work on macOS? Because I'm looking at https://www.qemu.org/docs/master/system/i386/hyperv.html as well as the QEMU source code and there doesn't seem to be any support for this outside of KVM (which as you may be aware is only on Linux). I couldn't find any reference to these features in HVF (which is for macOS). Are you sure your performance difference isn't just from disabling HPET?