Tuesday, June 28, 2011

Registry fragmentation

Most people know that fragmentation slows down a computer so you occasionally need to run a defragmenter. But did you know that the Windows registry can become fragmented in two different ways, and there are very few programs to defragment either type?

First, in case you are not familiar with the term fragmentation, basically the data is stored in different locations or fragments. It would be as if your pants were in your closet, your shirts were in the closet in another bedroom, your shoes were at the house across the street, etc. Because your clothes are in different locations it will take you longer to get dressed. In the same way, when computer data is fragmented it slows your computer down.

As I said, the Windows registry can be fragmented in two different ways. The first is the registry files can be fragmented just like any other file stored on the hard drive. Unlike other files on disk, registry files cannot be defragmented via normal means because the files are "locked" while Windows is running. The most common way to defragment the registry hives is to use SysInternal's (a.k.a. Microsoft) program PageDefrag.

The other type of fragmentation requires an understanding of the internal structure of the Windows registry hives. As I blogged about recently the Windows registry is a type of database. Data is constantly being written to, read from, and deleted from the registry. The way the registry is designed, when data is deleted the registry hive does not become smaller. Instead Windows tries to reuse that space in the future, but this ultimately will lead to fragmentation. A key point here to realize is the Windows registry never decreases in size, it only increases in size. Even if you delete most of the data in the registry, the file does not get smaller - and running PageDefrag will do nothing to help with this problem. But there is a way to reclaim this wasted space and defragment the registry at the same time. I recently wrote a program to do just that called HiveDefrag.

If you are like me you are probably wondering if either of these programs make any difference. So I ran some tests to find out. I took a computer that has been used for a long time (the longer a computer has been used the more likely the registry is fragmented and the slower the machine will be). I timed how long from power on until Windows was loaded and idle (i.e. all the startup programs had finished loading). I ran these tests multiple times and averaged the times to get the most accurate results.



I was surprised that PageDefrag had absolutely no effect on the machine's performance whereas HiveDefrag had a noticeable improvement. Yes, 4 seconds may not sound like much, but that was a 13% improvement.

I cannot guarantee every computer will benefit this much, but clearly this shows HiveDefrag can improve your system performance more than PageDefrag can. I would recommend every Windows user run HiveDefrag once a month to keep their system running at peak performance.

No comments:

Post a Comment