Keeping a guest cpu busy actually makes the guest faster?

Discussions about using Linux guests in VirtualBox.
Post Reply
940607
Posts: 57
Joined: 24. Sep 2012, 10:32
Primary OS: MS Windows 10
VBox Version: OSE other
Guest OSses: Archlinux
Location: Russia

Keeping a guest cpu busy actually makes the guest faster?

Post by 940607 »

Hi.
I have Arch64 guest on Win7 host. Main problem is: it mostly takes 2-5 seconds to rewrite a 100kb file residing on the guest's samba share. I also tried to upload and download the files between host and guest and the speed is unstable.

Surprisingly, running this shell command on guest in background workarounds the problem:

Code: Select all

for ((i=0;;i++)); do : ; done
This is my work PC. I also have a laptop with a similar setup and there's no such problem with it. Can it be some power saving misbehavior? Where to dig?

Code: Select all

- The version of VirtualBox you are using, and whether you have installed the Guest Additions (in the guest).
5.2.8 r121009 / no additions
- Host & Guest make and version including 32 or 64 bit, and the amount of memory available to both.
Host: Win7 Pro 64 SP1
  RAM: 24GB
Guest: Linux archlinux 4.15.9-1-ARCH #1 SMP PREEMPT Sun Mar 11 17:54:33 UTC 2018 x86_64 GNU/Linux
  RAM: 4 GB
Attachments
VBoxHardening.zip
(26.68 KiB) Downloaded 11 times
VBox.log
(96.93 KiB) Downloaded 12 times
Last edited by 940607 on 16. Mar 2018, 19:44, edited 1 time in total.
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Keeping a guest cpu busy actually makes the guest faster?

Post by socratis »

I'd start digging into the differences between your two hosts and/or the recipes for the guests. I don't have either of them in front of me, so I can't really tell you what the differences might be.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
michaln
Oracle Corporation
Posts: 2973
Joined: 19. Dec 2007, 15:45
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: Any and all
Contact:

Re: Keeping a guest cpu busy actually makes the guest faster?

Post by michaln »

Yes, it could be power saving (doesn't have to be, but could be). It's not "misbehavior", it's "working as designed". It is typical that when a CPU is not fully utilized, it runs slower. Keeping it busy forces it to run at full speed.
940607
Posts: 57
Joined: 24. Sep 2012, 10:32
Primary OS: MS Windows 10
VBox Version: OSE other
Guest OSses: Archlinux
Location: Russia

Re: Keeping a guest cpu busy actually makes the guest faster?

Post by 940607 »

Looks like I suffered from the odd number of vCPUs (3 in my case). I followed the FAQ advice to keep one core to the host and this is what happened.
940607
Posts: 57
Joined: 24. Sep 2012, 10:32
Primary OS: MS Windows 10
VBox Version: OSE other
Guest OSses: Archlinux
Location: Russia

Re: Keeping a guest cpu busy actually makes the guest faster?

Post by 940607 »

Nope. Two vCPUs didn't solve the problem.
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Keeping a guest cpu busy actually makes the guest faster?

Post by socratis »

940607 wrote:I followed the FAQ advice
What FAQ advice? We haven't even seen a VBox.log from you...
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
940607
Posts: 57
Joined: 24. Sep 2012, 10:32
Primary OS: MS Windows 10
VBox Version: OSE other
Guest OSses: Archlinux
Location: Russia

Re: Keeping a guest cpu busy actually makes the guest faster?

Post by 940607 »

The FAQ here : viewtopic.php?f=35&t=77413
says:
always keep a core ( not threads ) for the host so the host side code and host itself does not become over burdened
But again, reducing the cores from 3 to 2 didn't help. There are signs that with just one core network speed is stable.

I attached the logs to the opening post. During the test I was sending zeros to the xinetd discard service on guest on port 9. The guest network adapter is a host-only adapter.

Code: Select all

>/dev/tcp/arch64/9 pv /dev/zero
The pv tool was showing the current upload speed. While I was doing nothing else the speed was around 2 MiB/s. However, launching another upload made the sum of speeds grow to 140 MiB/s.
michaln
Oracle Corporation
Posts: 2973
Joined: 19. Dec 2007, 15:45
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: Any and all
Contact:

Re: Keeping a guest cpu busy actually makes the guest faster?

Post by michaln »

This is probably something related to scheduling. It is a well known problem that some workloads run slower with 2 CPUs than with one (and the effect is much worse in VMs). It happens with client/server workloads where the client generates a large number of requests for the server. With multiple CPUs, this ends up bouncing the work across CPUs and that just slows things down.

What probably happens is that when you keep one CPU busy in the guest, the workload you're interested in is forced to run on the other CPU, and it runs faster.
Post Reply