How to decrease the CPU usage when running Virtual Box?

12

1

I am facing an issue with 100% CPU usage under my system when running VirtualBox. Here are some further details:

My System Information:

CPU 1 name: Intel(R) Pentium(R) Dual CPU T2310 @ 1.46GHz
CPU 1 level 1 cache size: 32K Data cache. 32K Instruction cache.

CPU 1 level 2 cache size: 1024K Unified cache.
CPU 1 Mips: 2926.20
CPU 2 name: Intel(R) Pentium(R) Dual CPU T2310 @ 1.46GHz
CPU 2 level 1 cache size: 32K Data cache. 32K Instruction cache.

CPU 2 level 2 cache size: 1024K Unified cache.

CPU 2 Mips: 2925.96
64 bit CPU? Yes!
Total memory: 2.0 GB
Total swap: 6141 MBytes


My Operating System Information:

Kubuntu OS version: 11.04
Kernel version: 2.6.38-8-generic
Kernel arch: i686
Default shell: /bin/bash


My Virtual Box Settings:

OS Type: Windows XP
Video Memory: 32 MB
Acceleration: 3D
Base Memory: 512 MB

The Problem Details:

Well, each time I run Windows XP from my VirtualBox, I see the CPU usage at almost 100%. I experience a slow system even if no programs were running on my hosted Windows XP version.

I was wondering if there is a way for me to play with the settings so I can slightly enhance the performance. My PC is relatively fast under my Linux operating system. I need to know if there are some tips that I may follow when configuring the settings of my VirtualBox so i can achieve better results.

Any suggestions/ideas are highly appreciated!

CompilingCyborg

Posted 2011-05-28T07:48:32.313

Reputation: 251

So you mean your VM is running slowly, or your system altogether? The CPU you have is rather weak -- so I wouldn't wonder if it gets to 100% when you run VMs. – slhck – 2011-05-28T08:53:28.853

The CPU is slow, but I've been running XP on SUSE host on Athlon XP 2800+ with no problems and 2 GIB of RAM, and this system is many times faster than mine. It should be able to run VirtualBox and XP in neutral with no problems. Also +1 for nice list of relevant computer specifications. – AndrejaKo – 2011-05-28T08:57:23.440

I have been facing the same problem under several operating system on the same computer. Previously, I used Linux Mint, Ubuntu, Slax, Fedora and all it seems i was facing similar issues with the CPU usage. However, i believe if i can "properly" tweak the settings of my VM, i "might" be able to enhance the performance a bit. – CompilingCyborg – 2011-05-28T09:43:53.760

The temporary solution that i am using at the moment is an infinite loop that runs a bash command to free pagecache, dentries and inodes every 10 seconds. My VM was able to breath a bit after i thought of using this freaky technique though it is not a proper way of doing it but rather a "hack". – CompilingCyborg – 2011-05-28T09:49:52.333

1

Sadly the T2310 lacks Virtualization extensions VT-x (http://ark.intel.com/Product.aspx?id=32431) and as a result Virtualbox will be using software to catch all the high privilege cpu calls that the guest will make, this will mean that Virtualbox itself will be using more CPU power to cater for the guest OS. Also I'd be curious to see if giving the guest OS 1GB of RAM might help it idle better as it will not need to do Virtualbox-host-expensive page faults as often...

– Mokubai – 2011-05-28T10:06:29.160

Try running a lighter weight window manager than KDE. This should give you a bit of a performance boost. – Joe Internet – 2011-05-28T11:03:04.860

Answers

5

Elaborating on my comment above the T2310 lacks Virtualization extensions (VT-x) as per your CPU datasheet at http://ark.intel.com/Product.aspx?id=32431

From this Wikipedia article, there are three basic things that will be causing a measurable degradation in performance of the VM (and therefore an increase in CPU usage on the host:

  • Binary translation is used to rewrite certain instructions, like POPF, that would otherwise fail silently or behave differently when executed above ring 0 making the classic trap-and-emulate virtualization impossible. To improve performance, the translated basic blocks need to be cached in a coherent way that detects code patching (used in VxDs for instance), the reuse of pages by the guest OS, or even self-modifying code.

  • A number of key data structures used by a processor need to be shadowed. Because most operating systems use paged virtual memory, and granting the guest OS direct access to the MMU would mean loss of control by the virtualization manager, some of the work of the x86 MMU needs to be duplicated in software for the guest OS using a technique known as shadow page tables. This involves denying the guest OS any access to the actual page table entries by trapping access attempts and emulating them instead in software.

  • I/O device emulation: Unsupported devices on the guest OS must be emulated by a device emulator that runs in the host OS.

A guest operating system has a large overheard for operations that require the use of privileged instructions that are required and typically these overheads are heavily mitigated by the use of Intels VT-x and AMDs AMD-V virtualisation extensions. Your processor lacks these extensions and so all the work of capture and emulation will cause some performance loss.

My recomendations would be:

  • To give the virtual machine as much memory as it needs to minimise the amount of paging that needs to be done, perhaps 1GB or more depending on your workloads.

  • Disable the 3D acceleration as all the calls to the 3D driver may well have to be pushed through the emulation layer and so may be expensive on your processor.

  • Install the Virtualbox Guest Additions for your guest operating system as these will use drivers that better support the virtual environment.

  • Reduce the screen resolution and graphical options in your guest operating system.

  • Keep network (internet) access to a reasonable level, heavily network bound virtual machines are expensive even with VT-x and benefit from VT-d (Virtualization Technology for Directed I/O) as well, which is also not supported by your processor.

Mokubai

Posted 2011-05-28T07:48:32.313

Reputation: 64 434

2

My answer is related to the title of question only, not to other text of the question. My emphasis is on idle CPU usage with more virtual guests: (enough free memory on the host).

The CPU usage caused by audiodg.exe process on Windows host when running VirtualBox is higher than the load of iddle guest itself. It can be easily decreased or completely dropped out by disabling Audio checkbox in Virtualbox guest settings on the Audio tab. (Can be disabled only on closed virt. machine.)

The audiodg.exe process consumes approximately 5% CPU for one guest, but it's important load on a laptop during typical idle activities like source editing and it has a big impact on the CPU frequency (decrease from 80% to 40%), fan speed and battery life on laptop. Many of my running virtual machines usually does not need sound or only sometimes. (Disabling audio in the guest OS had no effect, neither pause of the virtual machine, but virtualbox guest settings are important.)

hynekcer

Posted 2011-05-28T07:48:32.313

Reputation: 121