[Front] [Prev Chapter] [Next Chapter]

Chapter 11 Improving Disk Performance

Optimizing a Disk

Caching Disk Data


This chapter describes two programs that you can use to make the best use of your hard disk or diskette drive.

Warning: Never use DISKOPT on a Windows 95 computer, even under DR-DOS. Use Windows 95 tools only.

Optimizing a Disk

DISKOPT is a "disk optimizer" that will improve the performance of a disk by doing the following every time you run it:

As programs read and write to the disk, files on the disk can become broken into multiple pieces of data that are stored in different locations. This is referred to as file fragmentation. It takes much longer for the system to read and write fragmented files than it does to read and write unfragmented files.

The areas of free space between files are made contiguous and moved to the end of the disk.

Optionally, DISKOPT can also do the following:

Before Running DISKOPT

Before you run DISKOPT, be aware that it can take some time, depending on the amount of data and degree of file fragmention on the disk. The more often DISKOPT is run, however, the shorter the time each DISKOPT operation will take.

You can stop disk optimization at any time by pressing the <Esc> key but do not attempt to reboot the system or switch off the computer while DISKOPT is still running.

Also, take the following precautions before starting DISKOPT:

Starting DISKOPT

There are two ways of using DISKOPT: interactively using the DISKOPT screen and menus or by using a command line. Either way, you start the program by entering the DISKOPT command at the system prompt.

Using DISKOPT Menus

Type the following at the system prompt:

DISKOPT <Enter>

Optionally, you can also specify the letter of the drive you want to optimize. If you do not, however, DISKOPT will provide you with a list of drives from which to choose.

The DISKOPT screen consists of four elements: a title bar, the optimization "methods," the legend describing the symbols used in the graphical representation of data on the disk, and the graphical representation itself.

NOTE: The default methods are displayed unless you specified different methods in the command line; see "Using the DISKOPT Command Line" on page 11-6.

Open a pull-down menu by clicking on it with your mouse or by pressing the <Alt> key along with the highlighted letter in the menu name.

Once a menu is open, you can move between the four menus using the <left-cursor> and <right-cursor> keys.

Close a menu by either selecting an option, pressing <Esc>, or clicking on it twice with your mouse.

Select any of the options in an open menu by clicking on them with the mouse or by moving the selection bar with the cursor keys and pressing <Enter>. You can also select an option by typing the highlighted letter in the option name. For example, to sort by date, press <Alt> S to open the Sort menu and then D to select the Date option.

Changing the Optimization Method

You can change the current optimization method (the method displayed on the screen) by using the Method menu. The options on this menu are as follows:
Menu Option

Explanation

Full Optimization

Defragments files and free space. No directory sorting is always the default.

Full Optimization with File Reorder

Defragments files and free space on the disk and moves files within the same directory so that they are physically adjacent. This method is slower than Full Optimization only.

File Defragment Only

Defragments files but not free space. This method is very fast but leaves gaps of free space between files.

Free Space Defragment Only

Defragments free space without defragmenting files.

Sort Directories Only

Sorts directories only; files and free space are not defragmented. Use the Sort menu to change the sort criteria (alphabetically by name is the default).

Full Optimization with Restack

Defragments the disk and recompresses data. Use this option on Stacker* drives which have been converted from DoubleSpace and SuperStor* drives.

Sorting Directories

If you chose an optimization method that includes directory sorting, you can specify the criteria for sorting by using the Sort menu. The options on this menu are as follows:
Menu Option

Explanation

Name

Sorts directory entries alphabetically by name. This is the default.

Extension

Sorts directory entries alphabetically by file extension.

Date

Sorts directory entries by date, from oldest to most recent.

Size

Sorts directory entries by size, from smallest to largest.

No sort

Leaves directory entries unsorted.

Starting Optimization

Start optimization, choose another disk drive, or cancel DISKOPT by using the Optimize menu. The options on this menu are as follows:
Menu Option

Explanation

Change drive <Alt> D

Allows you to specify a different disk drive.

Optimize disk

Starts disk optimization for the selected disk drive. You see a message indicating that DISKOPT is analyzing the disk. The screen reflects data movement while optimization is in progress. You see another message when optimization is finished.

Exit <Alt> X

Cancels DISKOPT and returns you to the system prompt.

You can interrupt optimization by pressing <Esc> and you can exit from the DISKOPT screen at any time by pressing <Alt> X. Do not, however, attempt to reboot the system or switch off the computer while DISKOPT is still running.

Using the DISKOPT Command Line

To bypass the DISKOPT menu options, simply enter the DISKOPT command followed by the appropriate command switches.

The full syntax of the DISKOPT command is as follows:

DISKOPT [/?|/H] [d:] [/B] [/Mx] [/O] [/Sx]

Command Switches

/? or /H

Displays help text.

/B

Specifies a monochrome (no color) DISKOPT screen.

/Mx

Specifies the optimization method, where x can be one of the following:

1

Full Optimization

2

Full Optimization with File Reorder

3

File Defragment Only

4

Free Space Defragment Only

5

Sort Directories Only

6

Full Optimization with Restack

/O

Starts optimization immediately. The optimization and sorting methods used depend on how you specified the /M and /S switches. The default method is automatically determined by DISKOPT; the default for /S is to leave directories unsorted.

/Sx

Specifies the directory sort criteria, where x can be one of the following:

a

Sort alphabetically by name.

e

Sort alphabetically by file extension.

d

Sort chronologically by date.

s

Sort by file size, from smallest to largest.

n

Leave unsorted.

Caching Disk Data

Because of the high degree of repetition built into DOS disk processing, caching disk data, which eliminates repetitive disk accesses, provides significant improvements in disk performance. A cache is an area in memory that keeps copies of the data read from and written to your hard disk and diskettes. When a disk read is requested, data that is already in the cache is delivered directly from the cache to your program. Because the data is already in memory, it can be delivered faster. When the cache is full, the least recently used data is discarded (or written to disk) to make space for newer data.

In DR-DOS, disk caching is provided by NWCACHE, which includes the following features:

The following sections in this chapter explain how to use NWCACHE and all of its features.

Memory Requirements

If DOS Protected Mode Services (DPMS) is loaded, NWCACHE will use it to load itself into extended memory. This means that the size of the resident NWCACHE code in conventional or upper memory can be kept down to maximize the memory available to your applications. For information about loading DPMS, refer to Chapter 10, "Managing Memory."

NOTE: The cache Lookahead buffer cannot load into extended memory. For more information about memory and the Lookahead buffer, refer to "Using Upper Memory" on page 11-18.

The resident memory requirements for NWCACHE are as follows:
Resident program:

5 KB

(10 KB if DPMS is not used)

Lookahead buffer:

4 to 16 KB

Control tables
(for extended memory cache):

0 KB

(1 KB plus 3 KB per megabyte of cache if DPMS is not used)

Control tables
(for expanded memory cache):

0 KB

NOTE: If your system configuration requires double buffering of disk transfers, an additional 2 KB of resident conventional memory will be required by the DBLBUF.SYS driver. See "Configuration Issues" on page 11-18 for more information about double buffering.

Various command options affect the placement and utilization of memory. See the next section, "Loading and Configuring NWCACHE" on page 11-9, for information about these command options.

If your system CPU is an 80286 and has extended memory installed, you should load the HIMEM memory manager before adding NWCACHE to your system. Using HIMEM resolves compatibility issues that arise when different programs attempt to share extended memory.

If your system CPU is a 386* or later, you should install the EMM386 memory manager before adding NWCACHE to your system. EMM386 allows using upper memory for program loading, and will allow you to convert extended memory to EMS memory if needed.

Refer to Chapter 10, "Managing Memory," for information about loading HIMEM or EMM386.

Loading and Configuring NWCACHE

The NWCACHE start-up command and its options determine the size of the cache and the type of memory it will use, which drives will be cached, where the cache program will be loaded, the Lookahead buffer size and location, and initial operational settings for the cache.

When NWCACHE loads into memory, it automatically caches all available disk drives; refer to "Selecting Drives to Cache" on page 11-13 for information about including or excluding specific drives.

The full syntax of the NWCACHE start-up command is as follows:

NWCACHE [/?|/H] [d[:]|d[:]+|d[:]-] [maxsize|minsize]
[/A20] [[/BE|/BL|/BU][=size]] [/CHECK]
[/DELAY=ON|OFF|time] [/E] [/L] [/LEND=ON|OFF]
[/MU[X]|[/ML[X]] [/W=size] [/X[=address]]

You can use the start-up command at the system prompt to load and configure NWCACHE. To load the cache automatically every time you start the operating system, however, use the SETUP program or edit the start-up command line in AUTOEXEC.BAT. Refer to "Using SETUP to Load NWCACHE" on page 11-11 for more information.
Table 11-1
NWCACHE Start-up Options

Options

/? or /H

Displays start-up help.

d[:]+

Forces caching of drive d with delayed write mode enabled. Refer to "NWCACHE Write Modes" on page 11-14 for information about write modes.

d[:]-

Excludes DOS drive letter d from caching. Note that you cannot use an NWCACHE control option to re-enable caching for a drive disabled at start-up.

d[:]

Forces caching of drive d as a write-through drive.

maxsize

Specifies the maximum size of the cache. By default, NWCACHE uses all available expanded or extended memory up to 7670 KB (the maximum size of the cache).

minsize

Specifies the minimum size of the cache. The default is based on the amount of available memory, as described in the section "Setting the Cache Size" on page 11-15.

/A20

Suppresses enhanced A20 mode, if you are using the extended memory cache. This option degrades cache performance, and should be used only when required to resolve unusual compatibility problems. Also, you can only use it if an XMS memory manager is not loaded.

/BE[=size]

Loads the Lookahead buffer into EMS memory and, optionally, specifies the buffer size (4 to 16 KB). The /BE option should be used with care, as some add-on memory boards are very slow and can reduce cache performance substantially.

/BL[=size]

Loads the Lookahead buffer into conventional memory and, optionally, specifies the buffer size (4 to 16 KB). This is the default. See "Setting the Lookahead Buffer Size" on page 11-15 for more information about the Lookahead buffer.

/BU[=size]

Loads the Lookahead buffer into upper memory and, optionally, specifies the buffer size (4 to 16 KB).

/CHECK

Enables a cache memory diagnostic test when the cache is started.

/DELAY=OFF

Disables write delay, and sets all drives to write-through mode.

/DELAY=ON

Enables write delay. The default is 5000 milliseconds.

/DELAY=time

Specifies the write delay value in milliseconds (50 to 5000). When the write delay value is 50 or more, write requests may be accumulated in the cache before being written to the drive.

/E

Forces the use of EMS memory for the cache.

/L

Forces the use of conventional memory for the cache.

/LEND=ON
/LEND=OFF

Enables or disables sharing of cache memory with other programs which require XMS or EMS memory. When lending is enabled, NWCACHE monitors allocation requests for XMS and EMS memory, and automatically reduces the cache size to fulfil the request. When the requesting program releases the borrowed memory, it is returned to the cache. Refer to "Sharing Cache Memory" on page 11-16 for more information.

/ML[X]

Loads NWCACHE into conventional memory. /ML overrides the default of using DPMS to load NWCACHE into extended memory; to load NWCACHE into conventional memory and into extended memory via DPMS, use the /MLX option.

/MU[X]

Loads NWCACHE into upper memory (memory addresses above 640 KB and below 1 MB), if available. /MU overrides the default of using DPMS to load NWCACHE into extended memory; to load NWCACHE into upper memory and into extended memory via DPMS, use the option /MUX.

Do not use this option if you are using Maximize (386MAX*), Optimize (QEMM*), or a similar product to assign fixed upper memory addresses.

/W=size

Sets the delayed write data limit (0 to 7670 KB). This option limits the amount of delayed write data which can be accumulated in the cache. If the limit is set to 0, write requests for all drives are satisfied immediately. If the limit is set to a non-zero value n, no more than n KB of delayed write data will be held back before writing. If you do not set this option, the entire cache area may be used for write data.

/X[=address]

Forces the use of extended memory for the cache. If no memory manager is loaded, but the computer has extended memory, specify the location of the cache buffer in address (above 1024 KB). You cannot specify the location if you have EMS memory.

Using SETUP to Load NWCACHE

You can load and configure NWCACHE using the SETUP program. Start SETUP, choose Disk Performance from the SETUP main menu, and then select the NWCACHE disk cache. The start-up command line will be added to AUTOEXEC.BAT when you exit SETUP and the cache will load automatically the next time you reboot the system.

If you load the cache using SETUP, you can also specify the following cache settings:

All other cache settings will be set to the default values. To change these settings, edit the start-up command line in AUTOEXEC.BAT yourself.

Refer to Chapter 9, "Configuring the System," for general information about the SETUP program and how to use it.

Controlling NWCACHE

The NWCACHE control command and its options allow you to display cache status, enable and disable caching, flush data from the cache, modify the cache program settings, and quit the cache.

The full syntax of the NWCACHE control command is as follows:

NWCACHE [/?|/H] [-|+] [d[:]|d[:]-|d[:]+]
[/DELAY=ON|OFF|time] [/Q|/U] [/S] [/SIZE=MIN|MAX]

Use the control command line at the system prompt after the cache is started. The next time you reboot the system or reload the cache after unloading it, however, the cache settings will return to the values set in the start-up command line.
Table 11-2
NWCACHE Control Options

Options

/? or /H

Displays cache control help text.

-

Flushes and disables the cache. This option completes any pending delayed writes, clears all drive data from cache memory, and disables the cache. Disk reads and writes are subsequently performed without caching, although NWCACHE remains in memory. You can re-enable caching with the + option.

+

Flushes and enables the cache. This option completes any pending delayed writes, clears all drive data from cache memory, and resets the cache statistics to zero. If the cache was previously disabled with the - option, caching is re-enabled.

d[:]+

Re-enables caching of drive d. Write delay enabled.

d[:]-

Excludes DOS drive letter d from caching.

d[:]

Identifies DOS drive letter d as a write-through drive.

/DELAY=ON

Enables write delay. The default delay is 5000 milliseconds.

/DELAY=time

Specifies the write delay value in milliseconds (50 to 5000). When the write delay value is 50 or more, write requests for delayed write may be accumulated in the cache before being written to the drive.

/DELAY=OFF

Sets all drives to write-through. This option completes any pending delayed writes and sets all cached drives to write-through mode. Write delay may subsequently be re-enabled, either for all the drives with the /DELAY=ON option, or for individual drives using the d+ control option.

/Q or /U

Quits the cache. This option completes any pending delayed writes, permanently releases all buffer, cache, and control table memory, and attempts to remove the cache program from memory.

NWCACHE may be unable to remove the cache program if another program has rehooked the system interrupt vectors. In this case, you must first remove the other program(s) from memory and then repeat the control command with the Q option.

/S

Displays cache status. This option completes any pending delayed writes before displaying the cache status.

/SIZE=MIN
/SIZE=MAX

Minimizes or maximizes cache size. This option completes any pending delayed writes, clears all drive data from cache memory, and either reduces cache memory to its minimum size or attempts to increase cache memory to its maximum start-up size.

Selecting Drives to Cache

NWCACHE automatically caches all fixed and removable disk drives. This includes any Stacker, SuperStor, or DoubleDisk compressed drives. RAM drives and remote network drives are excluded from caching as are CD-ROM or Bernoulli* drives and any other non-block devices.

You can use the d: and d:- start-up options to override NWCACHE's default selection of cached and non-cached drives. See "Loading and Configuring NWCACHE" on page 11-9 for more information.

NWCACHE Write Modes

NWCACHE supports three different protocols for writing data to the disk: write-through, buffered write, and delayed write. When you load and configure the cache during installation or SETUP, write-through mode is enabled for all drives, by default.

Write-through Mode

In write-through mode, write request data is written to the drive immediately. NWCACHE uses write-through mode to access drives with non-standard formats, which may not operate reliably with delayed or buffered writes. You can use the d: and /DELAY=OFF start-up options to override default settings and enable or disable write-through mode for specific drives. See "Loading and Configuring NWCACHE" on page 11-9. You can also use the d:, d+, /DELAY=OFF and /DELAY=ON control options to do the same things once the cache is loaded into memory; see "Using SETUP to Load NWCACHE" on page 11-11.

Delayed Write Mode

NWCACHE can be configured to access fixed disks in delayed write mode, in which write requests are held in the cache for a few seconds before the data is written to the disk. NWCACHE uses the delay to eliminate duplicate sector writes and to combine multiple write requests into fewer and larger physical writes, reducing the number of disk accesses and the time required for writing.

You can use the /DELAY=time option (start-up or control) to change the default write delay value. See "Loading and Configuring NWCACHE" on page 11-9 and "Using SETUP to Load NWCACHE" on page 11-11 for more information.

Buffered Write Mode

Diskettes and other removable media drives are normally accessed in buffered write mode. Buffered write processing uses the Lookahead buffer to combine successive write requests into a single disk write for faster access. Buffered writes offer many of the benefits of delayed writes, while maintaining data integrity when the removable media is changed.

Setting the Lookahead Buffer Size

NWCACHE uses a special area of memory called the Lookahead buffer to consolidate multiple read and write requests into larger read or write commands, to minimize disk activity and increase system speed.

Lookahead efficiency is a critical factor in system performance. If too few sectors are read in, sequential file access is slowed; if too many sectors are read in, random disk access is slowed. Lookahead continually monitors the pattern of disk activity to dynamically select the best Lookahead size for each disk transfer.

NWCACHE normally allocates 16 KB of resident memory to the Lookahead buffer. You can, however, use the /BL, /BU, and /BE options to force the buffer to load into conventional, upper, or EMS memory. The buffer is loaded in conventional memory, by default. Refer to "Using Upper Memory" on page 11-18 for more information about memory and the Lookahead buffer. You can also set a different Lookahead buffer size by specifying size when you use the /BL, /BU, or /BE option. See "Loading and Configuring NWCACHE" on page 11-9 for more information.

Setting the Cache Size

The maximum and minimum size values for the cache are set when the cache is started. These values are determined by the amount of memory available and by the minimum and maximum sizes specified in the start-up command; see "Loading and Configuring NWCACHE" on page 11-9. You can also switch between the minimum and maximum cache size values after start-up by using the /SIZE=MIN and /SIZE=MAX control options; see "Using SETUP to Load NWCACHE" on page 11-11.

If a cache size specification is included in the start-up command, NWCACHE attempts to allocate a cache of that size. If no cache size is specified, or if the specified size cannot be allocated, NWCACHE will allocate as much memory as possible to the cache. The initial allocation size is assigned as the maximum cache size value.

If a valid minimum cache size value is included in the start-up command, NWCACHE will set the minimum cache size to this value. If no minimum size is specified, NWCACHE establishes a minimum size based on the amount of available memory, as follows:
Available Memory

Minimum Size

to 384 KB

0 KB

to 512 KB

32 KB

to 1 MB

64 KB

to 2 MB

512 KB

to 4 MB

1024 KB

to 6 MB

1536 KB

6 MB +

2048 KB

Sharing Cache Memory

NWCACHE's /LEND option allows automatic sharing of cache memory with other programs. With lending enabled, NWCACHE monitors other programs' requests for allocation of XMS and EMS memory, and reduces the cache size if needed to fulfil the request. When the requesting program releases the borrowed memory, NWCACHE automatically returns it to the cache. The cache size is kept between its established minimum and maximum sizes during lending. Lending is enabled by default when you install NWCACHE but you can also use the /LEND start-up option to disable it. See "Loading and Configuring NWCACHE" on page 11-9 for more information.

Displaying Cache Status

Cache status is automatically displayed when the cache is loaded. You can also display cache status at any time after that by using the /S control command switch; see "Using SETUP to Load NWCACHE" on page 11-11 for more information.

The top portion of the cache status display shows the current cache memory size and type, the minimum cache size, the current write mode for the cached drives, and the cache options currently in effect.

If caching is disabled, the message Cache is inactive will be displayed. If Cache is inactive is followed by an error code, a serious problem exists. An error code of 99 indicates that some other program is writing data into NWCACHE's control tables. Any other error code indicates a problem with your system's memory manager.

The disk usage statistics include the following information:

The error statistics include the following:

The cache disk usage statistics are cleared and reset to zero whenever the cache is enabled or disabled. Disk error statistics are cumulative, and are unaffected by enabling or disabling of the cache.

Turning Off Power or Rebooting Your Machine

If you wish to turn off your system, first issue a cache disable command to ensure that any pending delayed writes are completed before the power is turned off.

The format of the cache disable command is as follows:

NWCACHE -

If you reboot your computer while delayed writes are pending, NWCACHE will complete all pending delayed writes before resuming the reboot sequence.

Configuration Issues

When you choose to enable NWCACHE via SETUP, a NWCACHE start-up command is inserted in AUTOEXEC.BAT, according to the options you choose in SETUP. Some configuration issues, however, especially the use of upper memory and correct load order, may require you to manually edit CONFIG.SYS or AUTOEXEC.BAT.

Setting DOS Buffers

The NWCACHE Lookahead facility greatly reduces the need for DOS buffers. For best performance, you should use 10 or fewer DOS buffers. This means your CONFIG.SYS file should set BUFFERS to 10 or less.

Using Upper Memory

If you are using a 386 (or later) computer, you may have upper memory available. NWCACHE will load into this upper memory by default, making more conventional memory available for running programs. NWCACHE may, however, still place the cache program or control tables in conventional memory if you do not have enough upper memory to complete loading. See "Loading and Configuring NWCACHE" on page 11-9 for more information about the /ML[X] and /MU[X] options.

The Lookahead buffer is loaded in conventional memory by default. You can use the /BU option, however, to load it in upper memory. If you experience problems when the Lookahead buffer is loaded in upper memory (when you are using certain SCSI systems, for example), try keeping the buffer in conventional memory or use double buffering (see the following section).

Double Buffering

Some SCSI disk systems do not operate normally in advanced CPU configurations and the system may "hang" when programs are loaded high. This may indicate a need for double buffering of disk transfers. The operating system includes a double buffering program named DBLBUF.SYS. You can enable double buffering by manually inserting the line below in your CONFIG.SYS file at or near the beginning of this file, before any lines which load memory or network device drivers:

DEVICE=C:\DRDOS\DBLBUF.SYS

DBLBUF.SYS must be loaded into conventional memory; do not attempt to load DBLBUF.SYS high.

Load Order

Loading programs in the correct order will avoid compatibility problems. The programs listed below are grouped into two categories, depending on whether they must be loaded before or after NWCACHE.

Load the following before NWCACHE:

Load the following after NWCACHE:

Other programs can be loaded before or after NWCACHE, as desired.



[Front] [Prev Chapter] [Next Chapter]

info@caldera.com
Copyright © 1993, 1997, 1998 Caldera, Inc. All rights reserved.