Windows Support Menu
File and Disk Administration
The time taken to start applications has long been associated with "software bloat." Microsoft discovered that although several performance metrics improve with a faster CPU, application start time did not improve significantly. Moving to a faster chip improved application launch times only on the order of around 3 percent. Research shows that disk I/O is the bottleneck and that disk seeks are the true culprit—a sector read takes an average of 2ms on current hard drives, while seeks to another sector takes an average of 12ms.
The goal of Defrag is to minimize seeks while launching an application. The new feature in Defrag works better on 4K cluster drives than it does on 16K or 32K cluster partitions. This is because memory pages are faulted in 4K chunks. A greater-than-4K cluster size is going to restrict how well a disk can be rearranged to minimize seeks. With 32K clusters, the second page that needs to be read during an application launch does not often fall in the same cluster as the first page to be read. With 4K clusters, these pages can be placed adjacent to each other. With larger cluster sizes, the 2 pages are forced to be non-adjacent due to the other information contained in the >4K cluster size.
Over time, as programs read from and write to a hard disk, information stored on the disk can become fragmented - that is, files are stored in noncontiguous sectors. Fragmentation doesn't affect the validity of the information - the files are still complete when they are opened.
It takes much longer for the computer to read and write fragmented files than it does for unfragmented files. Previous versions of the Disk Defragmenter optimized a disk by grouping individual files together in contiguous clusters.
Windows 98 Disk Defragmenter
While grouping clusters together is a good method for reducing the time to open files, what happens if several files used to open a program are not grouped together? Using the previous example, it is possible that two files used to open the same program are at opposite ends of the disk. This still produces a slow startup time for an application.
The significant change to Disk Defragmenter relocates the executable and supporting files of Windows programs to a single contiguous area of your hard drive. This placing of a program and all of its supporting files into contiguous disk space can significantly increase the speed at which the application loads and executes.
Disk Defragmenter is also different in that it can literally fragment program files to improve start times.
Optimizing the Optimizer
In order to get the most out of the new capabilities in Defrag consider the following:
Application Launch Optimization
Essentially there are three steps to disk optimization:
There is a small program—Taskmon.exe—that is constantly running and watches the Create_Process routine. When Create_Process is called, it checks registry settings for that process to determine whether or not it needs to log. If not, it does nothing. Otherwise, it loads Fiolog.vxd, which performs the disk trace.
Fiolog stops logging after 2.5 seconds of no loader activity for that process, and Fiolog.vxd is unloaded automatically after 10 minutes if it is not executing. This log is written to disk through file system lazy writing, to minimize the impact of system performance while the log is recorded. This generally happens shortly after the application has finished launching.
When Defrag is run, the from/to list is calculated based on the available Applog files and the list is fed to the defrag engine; then the defrag engine orders the clusters.
The new Defragmenter uses a process called autologging, written in conjunction with Intel, which tracks the order of program files accessed. During defragmentation, the program files are stored in a manner to produce the best loading time for applications. The priority is not to store files contiguously, but in the way they are loaded when the application starts.
Autologging works like this: The first time you launch a program after installing Windows 98, a folder named \applog is created in the Windows directory. Taskmon.exe monitors applications that you launch and creates a log file for each application in the %windir%\applog folder identifying all the files used to start the application. The log file is created the second time you launch an application.
The format of the log file name is application.lgn, where application is the name of the application and n is the drive letter where the application resides. The table below outlines sample log file name formats:
A sample of the Notepad.lgn file is below. Notice that the file identifies each file used. This file can also be used in troubleshooting customer's programs that do not run properly. For example, if a program GPFs when launched but at one time ran properly, the log file for that program can indicate which files are being called. You might be able to use the new SFC utility to expand specific files in your attempt to solve the problem.
Based on the information contained in a log file, Defrag may actually fragment files based on sequence of loading all the support files for a program.
The format of the Applog files is shown below. Microsoft does not support editing, rearranging, appending, rewriting or changing these files.
o -file_handle- -file_size- "-file_name-" // open file
Other Support Files
Microsoft Defragmenter uses the file, Applog.ind, to track which files are used and how often they are run. This binary file will increase in size as each program is opened. When you run the Microsoft Defragmenter for the first time, the Optlog.txt file is created that is a text file version of the Applog.txt.
The Optlog.txt file is generated the first time you run the Microsoft Defragmenter. This text file identifies the order in which programs will be organized on your drive based on how many times you have run a program. This optimization log also tracks program names, number of times each program is used, last execution date and the program's path.
Not all programs are eligible for the new optimization procedure. The Optlog.txt file also identifies which files will not be optimized as well as explaining why. A sample of the file is shown below
In the event that the Disk Defragmenter stops responding, it is possible that a log file has become corrupted. To solve this problem, delete the Applog folder, restart Windows 98 and run Disk Defragmenter again. The customer will have to reopen any programs to re-log the files. The Applog folder is recreated on restarting the system.
Logging Performance Hit
The one issue with automatic logging is that on occasion—usually the first time a user launches an application—it is going to take longer than it otherwise does, by nature of the system-generated the disk trace for optimization. Testing has shown that in cases where a log is generated, it can increase application launch time by up to 7%. This increase is due to the system writing part of the log to disk during application launch; because the file system lazy writer buffer is full, or another event occurred that forces the file system to flush its buffers.
Cases where a disk log is not generated have shown that TaskMon is not a detriment to general system performance or application launch time.
Registry information for Defrag is stored in
Registry Settings for TaskMon
The following shows the definitions for the registry keys that TaskMon uses:
Other Disk Optimizers
Third party disk optimizers may report that the drive is heavily fragmented after Disk Defragmenter completes because Disk Defragmenter literally fragments program files to improve start times.