VirtualBox running just a tad too slow

3

1

Summary: we are running an internet radio station in VirtualBox and we have the problem that the VM is running just marginally slower than real time, causing the audio playback to start stuttering after some time because the stream buffers are running low.

Here is the setup: we are running RadioDJ inside a Windows 7 virtual machine; the VM has 2 cores assigned and 2 GB RAM. The host OS is CentOS 7, running on an Intel Xeon X3440 quadcore with HyperThreading at 2.53 GHz (max) and 16 GB RAM; Linux reports 8 cores.

The VM runs fine with CPU load on both cores averaging around 25% and never maxing out. We produce 4 bitstreams (MP3 and AAC+) relayed through IceCast, and all suffer from the same problem: RadioDJ produces bits for the streams just a tad too slow, so after a few minutes the audio stutters because the stream buffers run empty. A listener either has to pause his player for a few seconds to re-fill the buffer or restart playback (*).

This VM used to run on another server without much of an issue (Xeon X3430 quadcore, no hyperthreading, 8 GB RAM). It was also a fraction too slow, but it would take 45 minutes before problems were noticable.

On the new server, the problems were much worse at first; the buffers would drain in 90 seconds. I calculated that the virtual CPUs were running 4.5% slower than real time.

So what I tried:

  • Assigning 1 core to the VM: no improvement.
  • Re-running Windows Performance index; no improvement.
  • Different virtual audio driver (see below); no improvement.
  • Setting the Paravirtualization in VirtualBox to Hyper-V: that did help a bit.

There is two possible culprits. One is the audio driver: RadioDJ requires a audiocard to be present but the new server doesn't have one. I suspect RadioDJ uses the card to time the audioframes and generation of bitstreams. So I am using the Null Audio Driver in VirtualBox and a virtual ICH AC97 soundcard for Windows. Still drifting... I installed VB Virtual Audio Cable in the hopes it would use CPU timing for a "true" 44100 sample rate. The problem is less, but still about 0.68% too slow.

The second culprit might be that the new Xeon has variable CPU speed (the old server seemed to be fixed speed), but setting the Linux governor to 'performance' didn't make much difference. In either case, Windows 7 can handle dynamic CPU speeds just as well.

One last interesting observation: I had the Windows Task Manager open all the time while typing this message and the Up Time counter seems to drift back and forth compared to wall clock time (by sheer coincidence I started the VM shortly before midnight so the Up Time nearly corresponds to my desktop time). So it looks like the VM isn't running that accurate... Drift is from +17 to +37 seconds.

The big question is: how do I get the VM to be running at 100% or, assuming RadioDJ does use the soundcard for timing, a true running (virtual) soundcard?

(*) I realize that due to slight differences in CPU and soundcard speed any playback stream might drift off and empty the buffer.

JvO

Posted 2017-08-23T00:14:19.097

Reputation: 883

Answers

1

Well, in the end I found a solution. I installed Virtual Audio Cable from Eugene Muzychenko and that works perfectly. It's a virtual audio driver that keeps perfect time. Interestingly the driver includes a very fine-grained clock correction so if you have hardware that really is drifting you can compensate even for that.

JvO

Posted 2017-08-23T00:14:19.097

Reputation: 883