My new KVM server build is almost complete, just need to add an USB Controller card. I’ll do a full write up once I finish the build.
The first VM I created had this terrible lag when starting stopping a video. Starting a youtube video would cause the video to play and then the audio would begin about 1 second later. Stopping the video would then pause the video while the sound continued for 1 second. So I went down the path of CPU pinning. I tried automatic numa without success.
AMD 2700X CPU
Xubuntu 18.10
I isolated CPUs 2-15 from the kernel. Isolation is working, I set up CPU Graph so I can watch the work load on each thread. CPU’s 8-15 are reserved for Windows 10 gaming VM. So I only have CPU’s 0-7 available for the kernel, emulator, and VMs. I only plan to run two non gaming VMs (Xubuntu 18.04), usually only one would be running and need to play videos in one of them. I could have both running at the same time but only one would be in use.
Here is what I did to get it working, made the following changes to the libvirt XML file:
<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
…
<vcpu placement='static'>4</vcpu>
<cputune>
<vcpupin vcpu='0' cpuset='4'/>
<vcpupin vcpu='1' cpuset='5'/>
<vcpupin vcpu='2' cpuset='6'/>
<vcpupin vcpu='3' cpuset='7'/>
<emulatorpin cpuset='2-3'/>
<iothreadpin iothread='1' cpuset='2-3'/>
When I set ‘emulatorpin cpuset’ and ‘iothreadpin iothread’ to share the kernal CPU (0-1) or the VM CPU’s (4-7) I get the sync problem, although not as bad. When these two settings have there own CPU it runs best, almost bare metal.
<cpu mode='host-passthrough' check='none'>
<model fallback='allow'/>
<topology sockets='1' cores='2' threads='2'/>
<cache level='3' mode='emulate'/>
CPU’s 0-3 are hardly working at all. I would like the kernal and emulator to run on CPU 0-1, is this unreasonable? Any suggestions to make this better and cure the video sync problem? I realize the current setup maybe the best setup.
I plan to setup a raid (mdadm) and cache drive (bcache) for the raid in a couple days, both running on CPU’s 0-1. I just wanted to sort out the non gaming VMs before I moved on.