r3dux.org

A number-pimping side project from the valleys in *NEW* upside-down flavour.

  • Home
  • ABOUT
  • OLD SITE
  • SEARCH
  • FEEDBACK

How To: Fix (Workaround, really) VirtualBox High CPU Load with Ubuntu 9.10 Host

r3dux | November 5, 2009

Updated to Karmic the other day, and all is well and good with the world, but VirtualBox is determined to use a heap of CPU time even when the guest OS is idling. This sucks, and from what I’ve read is related to CPU affinity.

I tried changing the affinity from 3 down to 1 with sudo taskset -p 1 31540 from the terminal, where 31540 was the PID (Process ID) of VirtualBox at the time – and did it work? Um, no…

After some further reading I found a quirky, but totally working fix workaround:
- Create a new virtual machine, call it “Dummy” or something
- Assign it as little resources as you can, like 4MB RAM, use a 10MB HD image etc
- Start this dummy virtual machine, skipping any virtual hard drive formatting
- That’s it! Just leave the dummy machine running at the screen saying “FATAL: No bootable medium found! System halted”

With the dummy machine running, VirtualBox sorts out its own processor affinity properly, and the CPU usage of your actual VM guest drops waaaaaaay down and becomes snappy & responsive again.

The joyz…

Update: This problem’s been recurring for me (as you can see in the comments below), but I think I’ve cracked it: With an XP guest running on a single core of a Core 2 Duo, if I run the following command in bash I can get the CPU usage down to negligible levels:

sudo su
echo 2 > /proc/sys/kernel/perf_counter_paranoid
exit

If this works for you and you want it to be applied at every boot, just edit the file /etc/sysctl.conf and add the line kernel.perf_counter_paranoid = 2 at the bottom.

Additional Information: Although perf_counter_paranoid 2 seems to work reasonably well – we can still do a bit better. With an XP guest, once you’ve set XP to use multiple processors, it’s going to keep trying to use multiple processors, even if you’ve told VB to only allow it access to a single CPU. To fix this you can grab yourself a copy of of HALu and change your XP CPU setup from ACPI Multiprocessor PC to ACPI Uniprocessor PC. With that in place, CPU usage for your linux host drops down a little further, and doesn’t ramp back up too far under minimal guest load. Or you could just use the dummy VM… FFFFFFUUUUUUUUUUUUUUUUUUU…. =P

Related posts:

  1. How To: Get Sound Working in Windows 7 64-Bit running in VirtualBox
  2. How To: Make VirtualBox Use Your Router’s DHCP to get an IP Address in Linux
  3. How To: Fix Compiz Starting When You Log In in Ubuntu 9.04
Categories
How-To, Linux
Tags
9.10, Dummy, High CPU, High Load, Idle, Karmic Koala, Linux, Ubuntu, VirtualBox
Comments rss
Comments rss
Trackback
Trackback
Print This Post Print This Post

« I’mma Let You Finish… How To: Convert a Directory of MP3s to WAVs in Linux »

11 Responses to “How To: Fix (Workaround, really) VirtualBox High CPU Load with Ubuntu 9.10 Host”

  1. Peter says:
    November 27, 2009 at 8:49 pm

    Had a bunch of problems after upgrading to Karmic and also this annoying problem with
    Virtualbox.

    But the above “fix”/workaround actually works so thanks!

    /P

    Reply
  2. nickg says:
    December 15, 2009 at 6:22 am

    Hi,

    At least using virtualbox 3.1 and ubuntu 9.10, I was able to fix the high CPU load by matching the “virtual CPUs” with the actual CPU (I have 2-core laptop). Which I think beats running another VBOX.

    enjoy!

    –nickg

    Reply
    • r3dux says:
      December 16, 2009 at 8:03 am

      Hey nickg,

      The current version of VB in the Karmic repo’s is 3.0.12 – and if I go grab the freshest build I’ll have to manually install each update so I’m holding off for now (laziness, I know ;) ) but I’ll definitely give your tip a whirl when the next version hits, as I’ve got my vboxen running on a single CPU out of the 2 physical ones on the core 2 duo to avoid them hogging resources…

      Cheers for your input!

      r3dux

      Reply
      • r3dux says:
        January 5, 2010 at 12:15 pm

        Finally bit the bullet and installed a non-repo version from the Sun website (3.1.2) – and as promised, setting the virtual box to use both physical CPUs has it running with low CPU usage. Good stuff.

        No good, no dice, no joy… CPU usage is still really high. Have dropped back to using a single CPU for my main XP guest and running the dummy box to keep CPU hogging down.

        I’ve tried disabling virtual memory in the XP guest, I’ve moved the virtual hard-disk over from IDE to SATA controllers (which I’ll post about soon) to try to improve the speed and lower CPU usage, I’ve lowered my linux host swappiness to 0 as with VirtualBox running linux was getting really swap-happy (think 500MB+) when I still had about a GB of RAM free…

        I’m installing another version of XP now to see if something’s just got mangled on the guest or if VB really is acting up. Will post results as I get ‘em…

        Reply
        • r3dux says:
          January 15, 2010 at 10:02 am

          Created a new virtual XP guest in VirtualBox 3.12, disabled all swapfile and indexing in the guest, minimised the number of running services, and set the virtual Hard Disk to run from a physically different disk in SATA mode (guide here) – then with the guest using a single CPU of the 2 available, the guest cpu usage ticks over between 1-2%, so no need for the dummy guest anymore. Nice :)

          Not tried using both CPUs yet – don’t really need to..

          Update: Noticed the CPU usage was waaaay up again when the XP guest was idling, tried letting the guest use both CPUs (and rebooting twice to be sure) – result was even higher CPU usage. Back to a single CPU and using the dummy machine gets CPU as low as I’m able, but it’s by no means perfect. This is starting to irk me. It’s irksome.

          Reply
          • r3dux says:
            January 19, 2010 at 9:27 am

            Think I’ve cracked it – check out the update to the article :)

            Reply
  3. baba says:
    December 18, 2009 at 11:43 am

    Same problem on Ubuntu 9.04, workaround work too :)

    Thanks a lot.

    Baba

    Reply
  4. Alex says:
    January 15, 2010 at 8:31 am

    Nice fix. Thank you. You saved me from a big headache and you contributed to energy saving:)

    Reply
  5. Safey says:
    June 17, 2010 at 3:27 pm

    Try running sudo kill STOP pid to squeeze out more CPU from the dummy.

    Reply
  6. Ad says:
    February 1, 2012 at 4:47 am

    Great tip. Complete opposite scenario – Windows 7 64 bit host, Windows XP guest, with CPU running up at 60% while the guest was idle. Created an ‘empty’ virtual machine, and immediately on starting it the CPU was down to 5%.

    Thanks for the tip :)

    Reply
  7. BK says:
    April 25, 2012 at 4:24 pm

    I know this is an older issue, but I just ran into the same problem running SuSe 12.1 with an AMD dual core cpu. I was able to get the idle time usage way down by limiting the number of CPU’s in XP to just one.

    1)Click start menu-> Run
    2) Type in msconfig
    3) go to boot.ini tab
    4) Click advanced options
    5) check /NumProc= and input 1 as the value.
    5) Restart your computer and Windows will only use 1 core on your core2duo

    CPU is still high on start up, but after XP finishes all its start up junk, CPU consumption is very low on idle and WinXP runs OK. I also removed as many un needed background processes as I could find.

    Reply

Leave a Reply

Click here to cancel reply.

Translate

Categories

Archives

Tags

3D ActionScript ActionScript 3.0 Adobe AI Ballarat Bash C++ Class Convert CS4 Effect Error Film Flash FPS GLFW Glitch GLSL Hack How-To install Java Kinect Linux Live Mash-Up Microsoft Motion mount OpenGL Particle Problem PS3 Remix Retro script Slides Sound Ubuntu Video VirtualBox Wii Windows XBox

Gamercard

OpenR3dux

Misc.

Flattr this

RSS Feed

r3dux twitter feed



“This time, like all times, is a very good one if we but know what to do with it.”

 - Ralph Waldo Emerson

rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox