I’ve spent the last few days integrating my new math library into the Windows project I started coding it for. Yesterday morning I was ready to try running the integrated copy, but I had some kind of problem starting it up. I couldn’t track it down very easily though, due to how long it took to do a full compile of that project.
As you might remember, I’m now using a MacBook Pro, and doing Windows development under VMware Fusion. I expected that things would be a little slower under VMware Fusion than on a bare-metal machine, and for the most part I didn’t really notice the difference… until I started working with this very large project again. I remembered it taking a long time to compile this one from scratch, but I remembered that “long time” as being closer to ten minutes. It was taking well over an hour now, which was simply ridiculous.
I’m also still running my Linux virtual machine at the same time, for web access and such. I had some trouble getting the two virtual machines to play well together… whenever I started the Windows VM, the Linux one suddenly started losing memory, for reasons I couldn’t understand. I tweaked the memory usage on both of them… it helped, but they still seemed to be fighting over memory at times, even though the system itself had plenty of memory for both of them and itself too, without swapping.
I finally found out the reason for all of that when I went to locate a fix for the slow Windows compiles yesterday. It turns out that VMware Fusion, unbeknownst to me, was sharing memory between the two, allowing the Windows machine to steal the Linux machine’s resources. (Just what I’d expect a Microsoft product to do. 😉 ). On VMware’s site, I discovered a page with a note at the bottom:
Adding the following settings to a virtual machine can reduce the I/O load on the hard disk, however these adjustments require additional memory on the host. Only add these settings if there is sufficient free memory on the host to accommodate all the memory allocated to the virtual machine, otherwise you may cause a memory starvation condition that can reduce performance of all the running virtual machines or possibly affect the host operating system.
I had plenty of memory, so bring it on! After shutting down the Windows VM, I added the four lines that the page suggested to the virtual machine’s vmx file:
MemTrimRate = "0"
mainMem.useNamedFile=false
sched.mem.pshare.enable = "FALSE"
prefvmx.useRecommendedLockedMemSize = "TRUE"
That helped, a lot. Not only with the speed of the compiles, either — the Windows system was no longer stealing the Linux machine’s memory. 🙂 But the compiles were still pretty slow, and it took me a while to discover why.
During a compile, I popped up the Windows Task Manager program, to see whether the system was swapping a lot of memory or something. And lo, what do I see, but that there’s another process who’s memory and CPU usage were going up while the compiler was trying to run. It turned out to be Microsoft Security Essentials, the free anti-malware program that I’d installed a little while back because the VPN software that one of the companies I work with uses insisted that I have some kind of virus protection. It was supposed to have no noticeable impact on the machine. Well, it had a very noticeable impact in this case.
After turning off its “real-time protection” option (and ignoring the dire warnings about how my computer was now At Risk!), full compiles were much faster. Still noticeably slower than on a similarly-equipped bare-metal system, but a lot more tolerable. I can’t say exactly how fast yet because I’m still improving it as I work on the code; I’ll run a thorough test once I’m done.
So equipped, I finally tracked down that startup problem — it was an instance of the static initialization order fiasco, which I should have thought of a lot sooner since I’d run into it just last week too. Oh well, live and learn. For now it’s back to the real task, developing the software.