Posted by: kurtsh | April 21, 2006

INFO: More on the topic of disk defragmentation from a Microsoft MVP

Here’s a bit of dialog I received from a Raxco engineer on the topic of disk defragmentation. 
 
Normally I ignore random emails/comments/questions from folks that don’t come from my customer’s domains – but in this case I’ve decided to make an exception, not because I agree with everything he says so please don’t consider this an endorsement, or think that the following will make your workstation run at Warp 9.9, but more because it is a set of interesting details that he put so much effort into writing about and has so much ridiculous passion around Windows File Systems.  God bless the MVPs.
 
Here’s part of the the mail I got from Raxco Engineer Greg Hayes:
 
[begin clip]
Bootvis is a wonderful tool for diagnosing boot time issues. Unfortunately, it is no longer available directly from Microsoft (however, you can find it on countless other sites).  [Editor’s Note:  Actually it’s still available from us… you can find it here:  http://download.microsoft.com/download/whistler/BTV/1.0/WXP/EN-US/BootVis-Tool.exe – ks]  Unfortunately, people’s perception of what Bootvis is used for is mostly incorrect.  I agree that it is a powerful tool to be used to diagnose drivers that are slowing down the boot process – indicating a driver that may not fully be compatible or optimized for Windows XP.  However, many people assume that Bootvis will auto magically improve boot speed.  They don’t realize that the mechanisms that Bootvis uses to speed up the boot process, Windows XP already is capable of performing on its own (with certain limitations). 
 
Windows XP does the same thing as Bootvis.  Both monitor the boot process and identify the drivers that load during the boot process.
This information is stored in the prefetch folder.  Windows takes advantage of this information to perform driver load optimization.  In addition, an attempt is made by both Bootvis and by Windows XP to group the boot files together on the drive so that they load faster – the recognition being that fragmented boot files slow down boot speed. 
 
The difference between what Bootvis is doing and what Windows XP is doing is that Windows XP monitors the boot process and after approximately 3 boots knows enough to perform the boot optimization.  Bootvis bases it on the results of a single boot.  The final step of both Bootvis and what Windows XP attempts to do (every 3 days) is to take the boot files and place them together on the drive.  This is accomplished via the built-in defragmenter’s command line interface in conjunction with the /B switch.  You’ll notice if you go to the command prompt and enter defrag /?, /B isn’t listed as a valid switch.  However, it is and what it does is tell the built-in defragmenter to attempt to congregate the boot files together on the drive.  Windows XP tries to do this approximately every 3 days as part of the idle task processing.
This exists as a non-displayed task that is run by Windows Task Scheduler. 
 
In order for this partial "defrag" to occur, an important thing must happen: there must be contiguous free space on the drive of a size large enough to hold all of the boot files.  During the partial defrag process, the built-in defragmenter doesn’t clear out free space to hold the boot files.  It depends on this contiguous free space already existing.  If this contiguous free space doesn’t exist, the boot file optimization (grouping the files together on the drive) doesn’t happen.
In addition, if there does happen to exist a large enough piece of contiguous free space, it may not be located in the best spot on the drive.  Instead of being at the beginning of the drive (where access is fastest), it is typically further in the drive – where drive speed isn’t optimal.  Ideally, what should happen is that the boot files should be placed adjacent to the MBR on the drive (at the beginning of the drive) so that the fastest boot speeds can be attained.  Due to the nature of Windows XP and the fact that Windows doesn’t identify boot files until after 3 boots, it is extremely rare for the boot files to be found at the beginning of the drive as the beginning of the drive by then is filled up with files and the built-in defragmenter doesn’t move these existing files out of the way in order to accommodate the boot files.
The optimization process (partial defrag) will only move them to where there is a large amount of free space – which is typically found further in the drive (slower part of the drive).
 
You also mention in your article about clearing out disk space and defragmenting.  I agree with you that Windows does need some space on the drive in order to function efficiently.  However, it isn’t the amount of free space available but the fragmentation of the free space that causes performance problems.  If free space is fragmented, then you do need 15-20% free space on the drive.  However, if free space is consolidated (defragmented), then Windows performs extremely well with as little as 5% free space.  Free space fragmentation affects write performance on the drive.  If free space is fragmented, it takes Windows longer to write files and the files that are written have no choice but to be written in a fragmented state.  Fragmentation = Wasted Disk Seeks = Performance Loss.  The key to providing best overall drive performance is to defragment files AND consolidate free space.  Defragmenting files improves read performance.  Consolidating free space improves write performance.  If you only do one and not the other, you are only providing half the performance improvement.  The built-in defragmenter – either in performing the partial defrag of the boot files or defragmenting the entire drive – simply does NOT do an effective job of consolidating free space (one of its many limitations).  As a result, free space over time gets very fragmented on the drive, which prevents boot optimization (partial defrag) from occurring, which slows down Windows in general as well as the boot process.
 
Ideally, what you would need to do is to defragment the drive – place the boot files together at the beginning of the drive, defragment files and consolidate free space.  This provides the best possible drive performance.  Unfortunately, things aren’t always ideal.  The built-in defragmenter only performs a small subset of this process and even 3rd party defragmenters tend to ignore free space consolidation or boot file optimization (and sometimes ignore both).
<end clip>
 

Greg Hayes
Systems Engineer
Raxco Software Inc.
http://www.raxco.com
Microsoft MVP/Windows File Systems

 

Categories

%d bloggers like this: