Prevent slow Linux performance on VirtualBox

Here is a quick tip if you are having slow performance with Linux running on VirtualBox:

Assign at least two processors to the Linux instance

Some background… My laptop came with Windows 7. I prefer to use Linux (currently Ubuntu) when developing and I really dislike dual-booting so installing Ubuntu side-by-side with Windows is not my preferred choice, mainly for two reasons:

  • I like to play games from time to time. Ubuntu is ok for this but Windows is still the winner.
  • Dell’s BIOS updates are released in .exe format and although I could probably run these from Ubuntu, I would not trust such critical updates to a non-native environment. Other drivers like graphics card drivers are also better supported in Windows.

So instead of replacing Windows or dual-booting I use VirtualBox to create a virtual machine environment for Ubuntu to run in. I have been running Ubuntu with 4GB of ram and 2 processors for a while now and it runs incredibly fast. For example, it boots in about 4 seconds.

Recently, I wanted to try out other Linux distributions such as Fedora, Debian, Xubuntu and Linux Mint and VirtualBox is perfect for testing. I gave each of these 1GB ram and 1 processor. They were all incredibly slow, even during installation. It felt like they ran more than 10 times slower than my Ubuntu installation. After thinking about it for a while, I tried simply increasing the processor count from 1 to 2 on each Virtual machine. Voila, they all had the same fast performance as my original Ubuntu installation. They are fast… very very fast!

So why did the processor count matter so much? I do not really know how to dive in and test it but my theory is that assigning just one virtual processor in VirtualBox is like assigning just one thread of one processor, if your processor is made by Intel and has Hyper-Threading technology. As you can see below, Windows Task Manager shows 8 processors even though there are actually only 4 (I have an Intel Quad Core i7-3612QM) so Windows seem to think that I have 8 processors. I know, I know, of course Windows knows about hyper-threading but it still seems to treat each thread as an independent processor.

Windows task manager processors

1 comment

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.