Since the day I first started using Windows Vista, I've observed inexplicable, and often seemingly random, fluctuations in startup times and performance. Much of the time, my Vista machines start up far slower than my XP machines, despite the latter being years behind them in terms of hardware. As hard as it might be to believe, my development machine, which has an Athlon 3200+ XP CPU running at 2.2 GHz. and one GB of RAM with EIDE drives, regularly outperforms my gaming machine, which has an Intel Core 2 Duo E6850 running at 3.0 GHz. and four GB of RAM with SATA II drives, at startup. It's quite absurd, isn't it, that a system so much older should outperform a system so much newer? I certainly think so, which is why I tried to fix it.
But to be honest I gave up quite a while ago. I got tired of spending my time trying to make the system startup quicker. And to be clear, dear reader, we're not talking about a few seconds here; I have better things to do with my time than try to fight Microsoft's bloated code to shave off a few seconds. No, when my Vista machines are slow to startup, I mean slow. I mean it takes nearly two minutes to go from pressing the start button to the logon screen. And then after I supply my credentials, it's another minute or more before Vista is done doing whatever the hell it's so doing (stupidly) before my desktop is ready for use. Two minutes may not seem like much, but with all the software that wants to update/restart constantly, it adds up rather quickly.
I can hardly believe it, but I think I have finally found the cause and, as usual, Microsoft is largely to blame.
It all started when I noticed that my gaming machine hadn't had its hard drives defragmented in a while. Every so often I do a quick check of the drives to make sure that everything is fine, and this time, roughly a week ago, I noticed that both of the drives were listed as being heavily fragmented by Diskeeper 2008 Professional Edition. A quick bit of digging revealed why: I had disabled the automatic defragmentation feature. Upon making that discovery, I remembered turning it off when the defragmenter was getting in the way of my video editing a couple of months ago. So when it came time for me to go to bed, I simply left the computer running and told Diskeeper to defragment both the hard drives.
It was when I restarted the next day that the pieces started falling into place. I needed to use the machine for some work, so I rebooted into its alternate Vista install and waited. And waited. And waited. I couldn't believe how slowly it was booting, but I figured that maybe Microsoft had installed some updates or something and the machine needed to handle the new files. I waited until I was finally at the desktop with no serious drive activity before doing a complete shutdown and powering up the system again. After multiple reboots failed to clear up the problem, I started to wonder: how could defragmenting the hard drives possibly make the system so much slower?
It probably wouldn't have been so jarring were it not for the fact that both installations of Vista had been starting up relatively quickly. I had actually been pleased with the startup time, particularly with the working configuration on the machine, so having the performance take such a leap into the toilet really caught my attention. It was a bit like a kick in the teeth—and not the good kind from some Buffy-esque hotty-slayer type but the bad kind from some ugly Hell's Angel named Rock.
But then I remembered something: Vista, like XP before it, tries to optimize its startup using a series of techniques designed to speed application/driver loading. If you look in your Windows directory, you'll find a folder named "Prefetch", which contains a whole bunch of executable images and other stuff. The point of all that, you see, is to make application and driver loading faster by saving to disk what the modules look like when actually loaded into memory. I know you might find it surprising that they aren't already that way on disk, but there's quite a difference between the storage needs for an application "living" on disk and how it looks when it's "living" in memory for actual use.
I should note that I've previously had plenty of problems with prefetch. Whenever I have freaky issues with games crashing, applications not loading, and the like, one of my standard troubleshooting steps is to delete the contents of the prefetch folder. And I'm sorry to say that this has solved quite a few bizarre and otherwise seemingly inexplicable problems. I don't know precisely how the prefetch system works, but I have m0st often noticed problems after driver updates, applying patches, and so forth. I suspect that Microsoft isn't doing a good enough job of keeping the cached versions of the software up to date in the prefetch folder, but of course that's speculation on my part.
What I do know for certain is that after I cleared out the prefetch folder, my next reboot was just as slow as the previous reboots, yet all my subsequent reboots have been much quicker. I haven't been able to repeat the experiment with quite as dramatic a set of results—perhaps because my drives are no longer so fragmented?—but I am nevertheless seeing a reliable pattern emerge. In short, if I defragment the disks my startup performance goes straight into the toilet, unless I subsequently delete the entire contents of the prefetch folder and then go through a few reboots. It seems that whatever system(s) optimize the Vista startup process are thrown for a loop by the defragment operation; either that or I suppose it could be that they do a much better job of optimization if the disk is already defragmented.
I don't know which is the case, nor do I understand why defragmenting the drive would throw the system into such fits of bad performance. I thought the whole point of the caching process was to make it easier to load the drivers/applications, and I thought the whole point of defragmenting the disk was to make sure that the files were all stored in contiguous clusters for fast, one-pass reads. As such, one would expect the two systems to be complementary, working hand in hand to provide maximum performance, but that's not supported by the timing data I've collected.
And yes, incidentally, I have tried using the defragmenting tool built into Vista instead of Diskeeper. I observe the same behavior from either, so I don't think it's a problem with Diskeeper. It seems to be a problem with the way the Microsoft prefetch system works. Either it can't cope with its disk images being defragmented, or it's not updating them properly, or something else. I'm not sure.
I cannot explain why two systems, which should theoretically complement one another, conflict in the way that defragmentation obviously does with prefetch. But if you're experiencing slow startup times with Vista—and the 'if' is pretty charitable in my experience—you should try clearing the prefetch folder. The difference is pretty astonishing on my machines. After a defrag, going from the logon to my desktop can take a minute or more, but after a prefetch clear and a couple of reboots it's more like five to ten seconds. The icons practically fly into my system tray. Since these findings are still rather preliminary, please drop me a line and let me know if you have results worth sharing.
06/20/2008