Wednesday, March 3, 2010

VMware Workstation 7: Improving Performance in 32-bit Ubuntu 9.10 (Karmic Koala)

I was in the process of tweaking an installation of x32 Ubuntu 9.10, and ran into some VMware performance issues.  Specifically, in VMware Workstation 7, I found that one of my virtual machines (VMs) performed much more slowly under 32-bit Ubuntu than it had performed under 64-bit.

To improve performance, I tried a couple of things.  I shut down the VM I was using, closed Workstation, typed "sudo vmware," and went into Workstation's VM > Settings > Hardware tab > Processors.  I had set it at 2, because I was using a dual-core processor, but I vaguely recalled that that had seemed slower at one point in the past, so I changed it to 1 processor.  I also increased Memory from 1000MB to 2000MB.  Also, while I was running Workstation as root, I went to Edit > Preferences > Memory.  I left Reserved Memory at 2500MB and changed Additional Memory to "Allow some virtual machine memory to be swapped," which as I recalled was the original setting.  I also thought that I might have been able to speed up the VM somewhat if it was smaller:  this particular one was 35GB, having been converted from a larger WinXP partition.  With these changes in place, I closed out of Workstation as root, started Workstation normally, and tried the VM again.  It was still very slow -- if anything, worse than before.  Some of this slowness could have been due to other hard drive activity.  I had recently installed Google Desktop, and it was indexing my hard drive throughout the time when I was writing this post.  But at this same time, another VM, set to 1 processor and only 1000MB of RAM, worked acceptably.

To speed things up further, there were numerous tweaks that would supposedly improve Ubuntu performance.  One speedup option was to buy a solid state drive (SSD).  This, it was said, would yield "a remarkable change in system performance - boot time and program startup times are drastically reduced. I highly recommend the investment - I have never before seen a single hardware change that affected performance as much as an SSD."  SSDs that would be large enough (30GB+) were currently at $150 and more, so that was something to think about for the future, as prices came down.  Getting an SSD would apparently call for some additional adjustments.

I ran a search to see if I could use the rest of my system's memory as a RAM disk.  This didn't seem to be a very common procedure.  But one post said it was simple.  The dominant approach seemed to be to tell Ubuntu to load its /tmp temporary files folder into RAM at startup.  There were different types of Ubuntu RAM disks.  The one called tmpfs seemed optimal.  The general idea seemed to be that you would set up tmpfs at a special location known as /dev/shm.  According to Kevin VanZonneveld, "The standard /dev/shm grows automatically as more space is needed, but is by default limited to half of your physical RAM. If you have 2GB, it can grow to 1GB at most."  There seemed to be ways to change that; but since I figured I'd typically have total RAM of 6GB to 8GB in my system, 50% of RAM seemed fine.  For future reference, there were ways to speed up Firefox by using tmpfs, but I hadn't noticed as much of a need for that, especially outside of the VMs.  What seemed most immediately promising, for my purposes, was to use /dev/shm for VMware specifically.  After some hunting, I found a website for VMware Server, but I wasn't sure whether I should try using its suggestions in Workstation.  I learned that KVM is an open source competitor with VMware but is still rather complex.  Then I noticed that someone said that a Physical Address Extension (PAE) aware kernel would allow 32-bit Ubuntu to use more than the (theoretically 4GB, but practically) 3GB RAM limitation.  I checked that out and concluded that 32-bit PAE performance was not going to be much better per se than plain 32-bit (and both would remain far below 64-bit performance), but neither would it hurt (unless I turned out to be one of those users who had problems with e.g., the mouse or graphics).  There was supposedly some performance reduction if you installed it in the standard way; the alternative was to build a custom kernel, which was beyond my time and abilities at that point.  I had just made an Acronis TrueImage backup, so I decided to try the standard approach, in its latest version.  First, I went to Synaptic and installed linux-generic-pae and linux-headers-generic-pae.  This did its thing for five minutes or so, and then said it needed to restart.  When the machine rebooted and got to GRUB, it showed me a new item:  "Ubuntu, Linux 2.6.31-19-generic-pae."  I selected that.  The BIOS told me, at boot, that I had 6GB of RAM.  When Ubuntu loaded, my previously opened windows were still in place (due to settings described in the previous post), but not VMware.  Instead, I had a dialog that said this:

VMware Kernel Module Updater

Before you can run VMware, several modules must be compiled and loaded into the running kernel.
So I went with that.  Meanwhile, I typed "free -m" and it reported that I did indeed have a total of 6050 of memory.  I wondered whether this would make any difference in VMware.  When the modules were done loading, I started VMware as root and increased the VM's allocation from 1000MB to 1500MB.  I also changed Additional Memory back to"Fit all virtual machine memory into reserved host RAM" and increased Reserved Memory to 5000MB of the 5472MB available to VMs.  Also, I changed the individual VMs to use 1500MB each.

Then I powered on the VM that had been working adequately before.  There was no question that it was much snappier.  With that one running, I powered up the other one, the one that had started the investigation.  So the additional memory definitely was available:  I had two machines running, where before I could only run one.  Now that I had two VMs up, the first VM, the better performer, was running more slowly.  The other one was still slow, but definitely was running better than before.  As before, the new Ubuntu kernel's audio started as muted, so I had to unmute it and turn it up, but then audio in both VMs worked.  There was stuttering in the second, larger VM.  To get the best performance, I turned off one VM and left just one running.  The memory enhancement had still not put me back to where I had been with 64-bit Ubuntu and 64-bit Workstation at their best, but if I got greater reliability and acceptable performance, that would be OK for now.  I did not pursue this further, though, because at about this time I began the process of upgrading to Ubuntu 10.04.