Excessive CPU usage when using VBoxManage guestcontrol exec

Discussions related to using the OSE version of VirtualBox.
Post Reply
jchatham
Posts: 19
Joined: 15. Jul 2013, 20:57

Excessive CPU usage when using VBoxManage guestcontrol exec

Post by jchatham »

I'm trying to track down the cause of some high processor usage in a couple of different virtualbox processes, and I see that there's an option to build virtualbox with "--build-profile", which supposedly enables profiling support... but I can't seem to find any further instructions on what to do next / how to actually get profiling information out of a running vbox process.

Can anyone point me in the direction of some answers?
Last edited by jchatham on 7. Oct 2014, 02:34, edited 1 time in total.
noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: How do I use the build-profile option?

Post by noteirak »

Moved to Virtualbox OSE
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: How do I use the build-profile option?

Post by Perryg »

You might want to ask this on the DEVs mailing list or IRC

https://www.virtualbox.org/wiki/Community
mhanor
Volunteer
Posts: 321
Joined: 7. Oct 2009, 12:40
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: various

Re: How do I use the build-profile option?

Post by mhanor »

All you need is to look at the source code. The profile build seems to enable some extra statistics, that can be viewed in the VboxDbg Statistics window (run the VM with --debug) or by running VBoxManage debugvm vmname statistics
jchatham
Posts: 19
Joined: 15. Jul 2013, 20:57

Excessive CPU usage when using VBoxManage guestcontrol exec

Post by jchatham »

So, for reference, the profile build also adds enough extra information into the code to allow linux utilities like perf to do their thing, which is (so far) seeming much more useful than any extra statistics.

And, now that I've verified this particular problem isn't a result of my own tinkering with virtualbox code, here's the situation I'm trying to fix:

If you run a VBoxManage guestcontrol exec command with the --wait-stdout or the --wait-stderr flag, then - even if the process you're executing isn't actually generating any output - the virtual machine will start using significantly increased CPU, jumping up from an idle value of typically 2-4% of one CPU core, up to 30-110% of one CPU core - even though the guest still shows itself as being 99% idle in both cases.

I have so far tested this with:
Virtualbox versions ranging from 4.3.8 through 4.3.16
Both Virtualbox (gui) and VBoxHeadless - these are the processes that show the increased CPU load, not the VBoxManage call!
Linux host (Ubuntu 12.04) and Windows host (Win7)
Windows guests (XP, Win7, Server 2003, Server 2008)

All of these configurations demonstrate this issue, though some more than others (a Win7 host running a Win7 guest was the worst offender, eating 110% CPU just to run ping through VBoxManage, while WinXP on a linux host "only" spiked up to about 30% CPU.)
jchatham
Posts: 19
Joined: 15. Jul 2013, 20:57

Re: Excessive CPU usage when using VBoxManage guestcontrol e

Post by jchatham »

So, I've figured this one out - the end problem here is that the windows guest additions don't support waiting for output, which results in the VBoxManage program polling in a busy loop. The immediate solution is to add some delays into the loop in handleCtrlProcessExec in VBoxManageGuestCtrl.cpp; longer term, I'm going to have to see if I can implement waiting for output in windows guest additions.
Post Reply