I often get to work with brilliant people. That’s one of the real benefits of being a consultant, I would argue. Last week I got to know Thomas Gyllencreutz, who came onboard my project. He didn’t waste any time in getting the performance in our virtual development environments to new heights. This post is a condensation of his findings that really got our Virtual PC images flying.
A general performance tip is to put your virtual hard drive (.vhd-file) on a separate hard drive, as suggested by Mr. Hanselman.
OK, to get the multi-core support you’ll need to find out how many cores your system has. The easiest way to do that is to open Task Manager (CTRL+SHIFT+Esc) and check the number of CPU boxes under the performance tab:
This guide expects you to have an existing .VHD-file—the one with the performance you want to boost ;). The guide also works from a Windows XP SP3 installation. You will need two files from its I386-folder (HALMACPI.DLL and NTKRNLMP.EXE).
Finally, if you haven’t already, enable hardware virtualization in your BIOS, if possible. That’s done differently on different systems, so I won’t describe it here.
To be able to use the settings we need (SMP), we’ll use the free VirtualBox, which can be downloaded here. When that’s installed, you can follow along here (sorry, I have translated the buttons from my Swedish installation):
- Make a copy of the existing hard drive (.vhd) to a new folder (e.g., VirtualBox/HardDrives).
- Start VirtualBox and choose New (virtual machine).
- Give the new machine a name and click Next.
- Set the amount of memory you need and click Next.
- Select “Use existing hard drive” and select the .vhd you copied in step 1 (VirtualBox/HardDrives). You’ll need to add it with another dialog:
- Click the little green arrow on the folder.
- Choose Add.
- Browse to the file.
- Click OK.
- Click Next and Finish.
We’re now ready to tweak the VirtualBox image:
- Right-click the created VirtualBox environment and select “Settings.”
- Click “System” in the left menu and select the following:
- Activate IO APIC (needed for SMP support).
- Select the number of processors you want the environment to use.
- Click “Screen” in the left menu:
- Select the amount of graphic memory you want the environment to have (I have 128 MB).
- Click “Audio” in the left menu:
- Uncheck Activate audio.
- Click “Network” in the left menu:
- Select Bridged network card and your physical system’s network card.
- Done!
When the VirtualBox environment starts up for the first time:
- Be sure to cancel the installation of all Windows drivers.
- Install the Guest Additions instead.
- Reboot the virtual machine.
Right – now we’re closing in on the final part:
- When the system is booted again, go to %WINDIR%\system32 and make copies (with new names) of these two files:
- %WINDIR%\system32\hal.dll to %WINDIR%\system32\halsp.dll
- %WINDIR%\system32\ntoskrnl.exe to %WINDIR%\system32\ntoskrnlsp.exe
- Now copy these two files from your Windows XP SP3 installation (I386-folder) to %WINDIR%\system32:
- HALMACPI.DLL
- NTKRNLMP.EXE
- Now we’re going to add a row in Boot.ini that is our configuration for multiprocessor support. Be very careful when doing this, as errors in Boot.ini may cause your system to not boot correctly.
- First, show protected operating system files in the Explorer (Tools -> Folder Options -> View).
- Now remove the write protection from C:\Boot.ini.
-
Open C:\Boot.ini and add the following row:
multi(0)disk(0)rdisk(0)partition(1)\WINNT="WinXP (native - SMP)" /execute /fastdetect /kernel=NTKRNLMP.EXE /hal=halmacpi.dll
- Save the file and write-protect C:\Boot.ini again.
- And better put back the hiding of operating system files.
- Shut down the environment.
- In the VirtualBox console, set the number of processors for your system.
- Start the virtual machine again.
- Wait a while for the system to find the drivers for your new configuration.
- Check the task manager in the virtual image; it should now have the number of processors of your choice.
Phew – that was a lot of stuff to do that I mostly didn’t know much about… But my virtual system is now flying! And I also got a lot better screen resolution. Full screen, baby!
Thank you, Thomas.