[SOLVED] Significant performance issues with a Windows virtual machine

Questions about virtualization software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
Suwakoto
Level 2
Level 2
Posts: 55
Joined: Wed Jun 09, 2021 2:07 pm

[SOLVED] Significant performance issues with a Windows virtual machine

Post by Suwakoto »

So, first off, here's the output of inxi -Fxxxrz:

Code: Select all

System:
  Kernel: 5.4.0-74-generic x86_64 bits: 64 compiler: gcc v: 9.3.0 
  Desktop: Cinnamon 4.8.6 wm: muffin 4.8.1 dm: LightDM 1.30.0 
  Distro: Linux Mint 20.1 Ulyssa base: Ubuntu 20.04 focal 
Machine:
  Type: Desktop Mobo: Gigabyte model: H81-D3 serial: <filter> 
  UEFI: American Megatrends v: F3 date: 01/20/2014 
CPU:
  Topology: Quad Core model: Intel Core i5-4460 bits: 64 type: MCP 
  arch: Haswell rev: 3 L2 cache: 6144 KiB 
  flags: avx avx2 lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx 
  bogomips: 25542 
  Speed: 798 MHz min/max: 800/3400 MHz Core speeds (MHz): 1: 798 2: 798 
  3: 798 4: 798 
Graphics:
  Device-1: Intel Xeon E3-1200 v3/4th Gen Core Processor Integrated Graphics 
  vendor: Gigabyte driver: i915 v: kernel bus ID: 00:02.0 chip ID: 8086:0412 
  Device-2: NVIDIA GP107 [GeForce GTX 1050 Ti] vendor: eVga.com. 
  driver: nvidia v: 450.119.04 bus ID: 01:00.0 chip ID: 10de:1c82 
  Display: x11 server: X.Org 1.20.9 driver: modesetting,nvidia 
  unloaded: fbdev,nouveau,vesa resolution: 1920x1080~60Hz 
  OpenGL: renderer: GeForce GTX 1050 Ti/PCIe/SSE2 v: 4.6.0 NVIDIA 450.119.04 
  direct render: Yes 
Audio:
  Device-1: Intel Xeon E3-1200 v3/4th Gen Core Processor HD Audio 
  driver: snd_hda_intel v: kernel bus ID: 00:03.0 chip ID: 8086:0c0c 
  Device-2: Intel 8 Series/C220 Series High Definition Audio 
  vendor: Gigabyte driver: snd_hda_intel v: kernel bus ID: 00:1b.0 
  chip ID: 8086:8c20 
  Device-3: NVIDIA GP107GL High Definition Audio vendor: eVga.com. 
  driver: snd_hda_intel v: kernel bus ID: 01:00.1 chip ID: 10de:0fb9 
  Device-4: ASUSTek Xonar SoundCard type: USB 
  driver: hid-generic,snd-usb-audio,usbhid bus ID: 5-1:2 chip ID: 0b05:189d 
  Sound Server: ALSA v: k5.4.0-74-generic 
Network:
  Device-1: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet 
  vendor: Gigabyte driver: r8169 v: kernel port: d000 bus ID: 04:00.0 
  chip ID: 10ec:8168 
  IF: enp4s0 state: up speed: 1000 Mbps duplex: full mac: <filter> 
  IF-ID-1: docker0 state: down mac: <filter> 
  IF-ID-2: virbr0 state: down mac: <filter> 
  IF-ID-3: virbr0-nic state: down mac: <filter> 
Drives:
  Local Storage: total: 1.14 TiB used: 1.01 TiB (88.3%) 
  ID-1: /dev/sda vendor: Samsung model: SSD 860 EVO 250GB size: 232.89 GiB 
  speed: 6.0 Gb/s serial: <filter> rev: 3B6Q scheme: GPT 
  ID-2: /dev/sdb vendor: Western Digital model: WD10EZEX-00BN5A0 
  size: 931.51 GiB speed: 6.0 Gb/s rotation: 7200 rpm serial: <filter> 
  rev: 1A01 scheme: GPT 
  ID-3: /dev/sdc type: USB model: Wilk GOODRAM 8GB size: 7.21 GiB 
  serial: <filter> rev: PMAP scheme: MBR 
Partition:
  ID-1: / size: 227.68 GiB used: 148.10 GiB (65.0%) fs: ext4 dev: /dev/sda2 
Sensors:
  System Temperatures: cpu: 34.0 C mobo: 29.8 C gpu: nvidia temp: 40 C 
  Fan Speeds (RPM): cpu: 1771 fan-2: 637 fan-3: 606 fan-4: 0 fan-5: 0 
  gpu: nvidia fan: 30% 
  Voltages: 12v: N/A 5v: N/A 3.3v: N/A vbat: 3.12 
Repos:
  No active apt repos in: /etc/apt/sources.list 
  Active apt repos in: /etc/apt/sources.list.d/kdenlive-kdenlive-stable-focal.list 
  1: deb http://ppa.launchpad.net/kdenlive/kdenlive-stable/ubuntu focal main
  Active apt repos in: /etc/apt/sources.list.d/official-package-repositories.list 
  1: deb http://packages.linuxmint.com ulyssa main upstream import backport #id:linuxmint_main
  2: deb http://archive.ubuntu.com/ubuntu focal main restricted universe multiverse
  3: deb http://archive.ubuntu.com/ubuntu focal-updates main restricted universe multiverse
  4: deb http://archive.ubuntu.com/ubuntu focal-backports main restricted universe multiverse
  5: deb http://security.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
  6: deb http://archive.canonical.com/ubuntu/ focal partner
  Active apt repos in: /etc/apt/sources.list.d/openshot_developers-ppa-focal.list 
  1: deb http://ppa.launchpad.net/openshot.developers/ppa/ubuntu focal main
Info:
  Processes: 260 Uptime: 8m Memory: 7.73 GiB used: 1.41 GiB (18.3%) 
  Init: systemd v: 245 runlevel: 5 Compilers: gcc: 9.3.0 alt: 9 
  clang: 10.0.0-4ubuntu1 Shell: bash v: 5.0.17 running in: gnome-terminal 
  inxi: 3.0.38 
I am using QEMU/KVM, with Virtual Machine Manager as the interface, to make a Windows 10 virtual machine with PCI Passthrough to play some games in. I have only one working GPU, so the PCI Passthrough is accomplished with a little script that runs at the start and end of the VM, disabling the graphical interface of the host, letting the guest grab the card and the screen it's connected to. The guest system has two cores and 4GB of RAM allocated to it.

The passthrough is working just fine, but I am having some serious performance issues. For one, I noticed that when I open images, they often take a long time to open, or if I have one open already and want to load a different one with arrow keys, Windows' Photos program will often freeze for several seconds. They're not big images or anything, not even FullHD, nor are they special. Just regular ol' PNGs and JPGs.

More importantly though, the games (which are the sole reason for the VM's existence) have some trouble running smoothly. They're not demanding titles, they're simple and old games that could run on an XP box from 15 years ago. The framerate is just fine most of the time, no trouble hitting the upper limit of 60 FPS, but they often have significant performance drops that are not related to anything in the games, they're just random. You can see the problem in this little clip: https://peertube.linuxrocks.online/vide ... 5791fe28b9 (Warning: I think the clip accidentally turned out quite loud, so lower your volume in advance. Not like the background music matters, anyway).

The FPS isn't perfectly stable, but I'll assume that's just because I was also recording it. But that huge dip halfway through has nothing to do with recording, I'm sure, because it happens even if I don't record. It also cannot be my hardware struggling to keep up, because it was not caused by anything special happening in the game, and... like, come on, the game's from 2002, surely two cores, 4GB of RAM and a GTX 1050Ti is enough to run that?

To try and get more data, I made another virtual machine, with pretty much an identical setup as the Windows one (same script, same devices connected, same resource allocation, etc.), except this time it was running Artix Linux instead of Windows. Running the same game inside that VM with Wine produced perfectly smooth and stable 60 FPS that never dips or staggers.

Any idea what is it about Windows that might be causing this?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
gittiest personITW
Level 12
Level 12
Posts: 4286
Joined: Tue May 28, 2019 4:27 pm

Re: Significant performance issues with a Windows virtual machine

Post by gittiest personITW »

If the games run on XP, then why not install XP in the VM?
Suwakoto
Level 2
Level 2
Posts: 55
Joined: Wed Jun 09, 2021 2:07 pm

Re: Significant performance issues with a Windows virtual machine

Post by Suwakoto »

gittiest personITW wrote: Wed Jun 09, 2021 4:36 pm If the games run on XP, then why not install XP in the VM?
Well, at least two games work on XP, but others probably need something like Vista or Win7. Whichever I'd go for, though, there's the matter of finding an ISO to use. Microsoft provides free downloads of Windows 10, but for the other systems I don't really know any reliable sources that don't come with the risk of having malware included... or that are legal.

Besides, there are some other pieces of software that I use on the VM that also would require at least Windows 7 (Nvidia's GeForce Experience, for example), so yeah, in practice it's just a choice between 7 and 10, 10 I can get legally for free, 7 would require some questionable scavenging, and I can't even be sure that it'd fix the issues I'm having.
gittiest personITW
Level 12
Level 12
Posts: 4286
Joined: Tue May 28, 2019 4:27 pm

Re: Significant performance issues with a Windows virtual machine

Post by gittiest personITW »

Fair enough.

4GB RAM is pushing it with Windows 10 as it is and even if you were running Win10 (without running Mint at the same time) you wouldn't expect it to be a gaming machine. Assuming you are letting Win10 use the spinny drive rather than SSD also?

Could you try allocating more RAM, or, at a push, install Mate and see if that would free up more resources for Win10?

Anyway, if you get into your VM as it stands, run Win10 and the most hungry games/apps, can you check in Mint how many resources are being taken up? This might help to indicate whether hardware is a limitation vs whether it needs tweaking or different drivers within Win10.
Suwakoto
Level 2
Level 2
Posts: 55
Joined: Wed Jun 09, 2021 2:07 pm

Re: Significant performance issues with a Windows virtual machine

Post by Suwakoto »

gittiest personITW wrote: Thu Jun 10, 2021 6:32 am4GB RAM is pushing it with Windows 10 as it is and even if you were running Win10 (without running Mint at the same time) you wouldn't expect it to be a gaming machine. Assuming you are letting Win10 use the spinny drive rather than SSD also?
4GB of RAM is what's given exclusively over to the virtual machine when it's running. My system has a total of 8GB available, so when I run the machine, Mint has 4GB left for itself (which is probably overkill; without GUI, it could probably subsist on just 1GB).

I actually don't use the hard drive for the VM. I used to have a partition for Windows on it that I used for dual boot, but solid state spoiled me so much that running a system off an HDD feels unbearably slow. No, I have a 50GB virtual hard disk sitting on the SSD, that's where the machine's storage is located.
gittiest personITW wrote: Thu Jun 10, 2021 6:32 amAnyway, if you get into your VM as it stands, run Win10 and the most hungry games/apps, can you check in Mint how many resources are being taken up? This might help to indicate whether hardware is a limitation vs whether it needs tweaking or different drivers within Win10.
I opened PowerShell and used the SSH command to log into Mint from inside Windows, and then ran the htop command to look at how the system was doing resource-wise. And I found the solution to the problem.

RAM was not the issue, but the CPU. When setting up the VM, I allocated two cores to it (1 socket, 2 cores, 1 thread), but when the VM was running, it would max out one core and the others would sit idly. From looking at how a running game behaved, it seemed that the lags occured most frequently when the occupied core was changing, i.e. it was going from C1: 5%, C2: 5%, C3: 100%, C4: 5% to C1: 5%, C2: 100%, C3: 5%, C4: 5%.

Looking up the CPU configuration in Virtual Machine Manager, it had the Maximum Allocation set to 2, but the Current Allocation was set to 1. I increased that to 2, and once again tried playing something in the VM while checking performance. Sure enough, the load was distributed more evenly and the lag spikes were completely gone, as were the random freezes during other activities.

So basically, through a bad configuration, I was running Windows 10 on a single CPU core and complaining when it chugged :D
gittiest personITW
Level 12
Level 12
Posts: 4286
Joined: Tue May 28, 2019 4:27 pm

Re: [SOLVED] Significant performance issues with a Windows virtual machine

Post by gittiest personITW »

Glad you found the problem and well done for posting the solution.
Locked

Return to “Virtual Machines”