At work we use a lot of virtual machines running in Virtual PC, VirtualBox and vmware, I’ll call them VPC. Basically we set up a VPC with a development environment for each customer, and thereby keeping a clean development environment which can be passed between developers easily. There are many advantages in doing it this way. For instance some projects require VPN connection to customer systems to access DB/webservice/SOA. This VPN connection will block out all your LAN and internet traffic from the local computer. Doing this from within a VPC not only leaves your host PC free to access LAN/internet, but is also more secure because there is less chance of any malware or hackers accessing the relatively clean and untouched virtual machine. Using VPC’s this way also ensure that the development environment is clean and not tainted by other projects and the general use a computer goes through. It can even be guaranteed virus free if you behave properly.
VPC’s are actually performing pretty well nowadays, but there is always some small tweaks you can make to make it go faster.
So I’ve put together some tips from the top of my head… I’ll edit this post as I remember more.
- Always install the virtualization tools
They contain hardware drivers to speed up things and makes the VPC more user friendly.
- Turn on “Intel VT (Virtualization Technology)” or “AMD-V” in your BIOS
There is no drawback in doing this and it will speed up the VPC. I’ve heard at a seminar a few years back that the performance increase was around 20% in some scenarios. But with modern virtualization software would guess it is less. Either way it won’t hurt enabling it. In short this option enables more of the VPC to run directly on CPU instead of going through the virtualization software. All modern CPU’s have this feature.
- Use fixed sized disks
Using dynamically sized disks leads to bad performance. The VPC will increase the HD file size on demand (as you use it inside the VPC). The problem is that your usage is not sequential starting at start of disk and going out. Look at the disk in Computer Management->Defrag->Analyze and you will see a few holes. If the HD file is not increased sequentially then you will get fragmentation which is one of the worst bottlenecks you can have on a computer. You may end up with a fragmented file system inside the VPC located in a fragmented file on the your physical disk. Defragmenting inside VPC will not solve the problem, you would have to defragment the physical disk as well.
- Balance RAM usage fairly between host OS and guest OS
If either one runs out of RAM then it will start using the harddisk and this will slow down both.
A common mistake is to give the guest OS less RAM because its not considered that important. However if the guest OS must swap memory to disk it will slow down considerably both itself and the host OS.
- Ask antivirus software to ignore VPC files
Antivirus software will scan all data being read/written to disk. If it scans VPC files then two things may happen: 1) VPC speed decreases, 2) antivirus may falsely identify a portion of the VPC harddisk as virus and block access to it, hence crashing the VPC. This benchmark contains information about performance on various antivirus.
- Set Server to prioritize foreground programs
Windows Server comes with kernel scheduler default set to schedule (share CPU/memory) evenly between background programs. If you are using the VPC as a development platform you probably want to change this. 1) Right click “My computer”, 2) choose Properties, 3) only for Windows 2008 server: click “Advanced System Properties”, 4) click Advanced, 5) click Settings in Performance, 6) Choose “Programs” in both radio boxes.
- ReadyBoost works for guest OS too
Windows Vista, 7 and 2008 Server supports ReadyBoost. ReadyBoost can use devices such as USB pens and memory cards for temporary caching of data. ReadyBoost uses the fact that harddisks and flash memory has different properties, or different things they are good at. If you don’t have enough RAM for either host OS, guest OS or both then using a USB-pen can give you a considerable boost. Basically you have two OS that share one disk, so any offloading of the is good. ReadyBoost will compress and encrypt the memory data, so a 4GB USB pen can give up to 8GB more “RAM”.
Note: If you run the VPC over USB or network then assigning a USB-pen as ReadyBoost can speed up the VPC considerably.
- Compress guest OS file system?
Do not compress the host file system where the VPC is located. This will only lead to a bad case of fragmentation illness.
You can however consider compressing the guest OS. The thought here is that CPU’s today are so fast compared to any disk activity that if you can decrease the amount of data being read/written to disk it will actually speed up your computer. Remember to defragment your file system heavily after compressing it.
Note that using compression has some drawbacks. It will work fine for static files, but for files you change often you should consider not compressing them.
Note2: Some people believe compression will speed up IO, others don’t. I think its pretty clear that combining it will regular defragmentation will speed up IO to an average of around 200%.
Note3: SQL and Exchange can not run if their databases are compressed.
Note4: Compressing folder with images, videos or compressed files (i.e. install files) won’t give you any speed increase, but can lead to fragmentation.
- Defragment, then defragment some more
Defragment both host OS and guest OS harddisks, and do it well. O&O Software has some nice (commercial) products. Schedule defragmentation for every week if possible. You can greatly benefit from a professional defragmentation utility because they will place files in order of access. The way harddisks works they will assume that you are reading a big sequential file, so they will pre-fetch additional data from the point you are reading. If files are defragmented by access time then chances are the harddisk will pre-fetch the next file even before the OS knows that it needs it. Sequential data reads are fast. Fetching 0.1 or 1 MB is about the same work for the harddisk because it has already done the majority of the work when moving the read heads to the correct location.
- Disable last access date
Doing so will not make it possible for defragmentation program to put files in access sequence. However it will eliminate the need of writing to disk every time a file is accessed. You can do this by executing the command: FSUTIL behavior set disablelastaccess 1
- Make sure both host and guest have 20% fre
File systems will always attempt to avoid fragmentation. But they are unable to do this when the harddisk starts to fill up.
- Snapshots and undo-disks will slow VPC down
Snapshots and undo-disks are two very useful features that seem instant. What actually happens is that the virtual machine creates a second hard disk file to write differential data in. This means that for every write the guest OS make the data is not written to the correct place in the original HD file. The guest OS file system defragmentation feature will not work.
- If you are running VPC from a USB disk or network share then give it more RAM
VPC’s can run from USB disks or even over network, but they will be slightly slower. Give it more RAM to compensate, it will use less disk for memory swapping and keep as much commonly used files in memory as it can.
Note: As mentioned above ReadyBoost can give VPC’s running remotely a boost.
- Run VPC on separate physical disk from host OS
If you are using a desktop computer then consider getting another disk. If your VPC don’t contain anything important (i.e. all code is kept in source repository) then considering running 2 disks in RAID-0 STRIPE (double speed.) The disks are without a doubt the biggest bottleneck on your computer, and if either host OS or guest OS use the hard disk they will slow down each other.
- Multiple disks for swapping
If you have an extra physical disk in your host computer then you can make a new virtual disk for the guest OS and put there. Then tell the guest OS to use that one (or both) disks for memory swapping.
- If you can, buy better disks
Disks are the bigest bottleneck. If you are running from a laptop then your disk may be 5400RPM. Get a 7200RPM disk!
Using RAID-0 STRIPE (risky) or RAID-5 can almost double your disk speed (or even more if you really invest.)
Note: Don’t run RAID-5 on a computer that doesn’t have battery backup for its RAID-memory. No battery/nvram = background check of all disks for consistency after power outage/bluescreen/crash. In other words the vanilla desktop PC RAID-5 is just plain stupid. RAID-10 (STRIPED MIRROR) can give you good speed and security.
- If you can, but more RAM
RAM is cheap and having enough RAM is very, very important. People tend to forget exactly how important it is. More RAM will speed up your computer. Unless you have very specific CPU-bound needs I’d recommend buying large amounts of cheap RAM instead of lesser fast RAM (if you have to choose). Buy as much as you can of RAM with normal speed. I have 8GB in my desktop computer and it is usually enough, but I notice a big difference when I start a VPC and give it half.
- Consider mapping VPC directly to physical disk
A VPC will normally map its virtual hard disk to a file on the host OS. This means that any file access inside the guest OS has to go all the way from program->guest OS kernel->guest OS file system (with fragmentation)->host OS kernel->host OS file system (with fragmentation)->physical disk. The virtual machine allows you to bypass the host OS by using a partition directly. Note that the extra layer of host OS is handled fairly well by modern operating systems, but still the benefit is there in using direct mapping.
Tip: By using hardware profiles on guest OS and tinkering with c:\boot.ini on host OS you can actually choose to boot the guest OS as host OS during host computer boot. The hardware profiles will make Windows hold two separate hardware profiles, one for virtual machine and one for physical machine. You can then in both run the other as a guest OS.
- Split files is good, esp. for dynamic disks
VMWare supports splitting virtual machine HD-files into many (smaller) files. If you are using dynamic sized disk then it is advisable to use this feature as it will slightly help prevent fragmentation and are much easier to work with and defragment on host OS.
- Enable extreme caching if you are tough/stupid enough
If you can afford to loose some data in the guest OS in case of a power outage or crash/bluescreen then you can increase the write speed and usage of the hard disk. When you write to disk Windows will keep the data in memory until it has enough to do a write operation. This way many small writes becomes one large. The problem is that if your computer crashes then the data in memory is lost – leading to corruption in database files, windows/registry, all your last work missing, etc.
Open Device Manager: 1) Right click “My computer”, 2) choose Properties, 3) only for Windows 2008 server: click “Advanced System Properties”, 4) click Hardware, 5) click Device Manager
Set caching policy: 1) Expand “Disk drives”, 2) right click your hard disk, 3) choose Properties, 4) choose Policies, 5) select your caching level. The levels are explained there.
- Windows 2003 uses a lot less resources than Windows 2008
So choose visely… 🙂
- Use NTFS file system
If you are using FAT then turn around and go home! FAT is a very bad file system compared to NTFS in so many ways that I won’t even attempt to cover it here. NTFS is faster, more secure (disk errors), more secure (user permissions) and requires a (very much) less RAM.
- Working with a lof of files?
If you have many files (100.000+) on your file system you may want to increase the NTFS MFT (file table) size. NTFS will store any file less than 4096 bytes directly in its file table making it much faster to access. If you have a lot of files, especially small ones, then the MFT may grow out of its originally allocated size. This will cause it to become fragmented and slow down file access.
Execute commands to set appropriate level:
Reserve 12.5% disk space for MFT (default): Fsutil behavior set mftzone 1
Reserve 25% disk space for MFT: Fsutil behavior set mftzone 2
Reserve 37.5% disk space for MFT: Fsutil behavior set mftzone 3
Reserve 50% disk space for MFT: Fsutil behavior set mftzone 4