A Program to Optimize the BUFFERS= Setting
W. G. Madison
W.G. Madison and Associates, Ltd.
8425 Greenbelt Rd. #101
Greenbelt MD 20770
May 15, 1987
Acknowledgment: This program is based upon ideas gleaned from the
public domain program THRASHER, by Monte Ferguson of Ravenna, OH.
Disclaimer: This program is provided AS IS, with no claim for
suitability for any particular purpose. Specifically, since the
program is necessarily extremely disk intensive and therefore
exercises the head positioning mechanism far more than is custom-
ary in normal use, the Author and W. G. Madison and Associates,
Ltd. disclaim any and all responsibility for actual and/or con-
sequential damages to hardware and/or files resulting from the
use of this program.
All personal computers using the DOS operating system (PC-
DOS, MS-DOS, etc.) use buffered I/O when reading from or writing
to the disk, unless the programmer who wrote the software being
used went to great lengths to avoid it. The number of buffers
used is specified in the file CONFIG.SYS, which is read at the
time the computer is booted up.
If you are not familiar with the CONFIG.SYS file or with the
concept of buffered I/O, it is strongly suggested that you refer
to your DOS reference manual before proceeding further.
The problem of determining the proper number of buffers with
which to configure a DOS computer is, at best, inadequately add-
ressed in most DOS reference manuals. Generally, the suggested
approach is "Try a number, then use your computer, then try
another number. Keep repeating this process until you are either
fed up or have arrived at something which gives acceptable per-
formance." Some reference manuals give a suggested value to be
used by those looking for an easy out. This suggested value may
or may not yield performance which is close to optimum.
DiskBuf provides a method for scanning through an entire
range of values while you go out for coffee (or something
WHY WORRY ABOUT THE NUMBER OF BUFFERS?
As might be expected, buffering uses RAM. Specifically, each
buffer added to a DOS system uses 33 paragraphs (528 bytes) of
RAM. Assuming that plenty of RAM is available, it might be tempt-
ing to take the approach, "Let's just set the number of buffers
way up, and fly with that." Unfortunately, one can reach the
point where more time is spent searching buffers for information
than is necessary or desirable. A point of diminishing returns is
Similarly, too few buffers will cause the computer to go to
the disk more often than necessary. And, since disk operations
are dreadfully slow in comparison to memory operations, unaccept-
able performance degradation will result.
WHY USE THE DISKBUF PROGRAM TO SOLVE THE PROBLEM?
Basically, without an intimate knowledge of the insides of
DOS plus a penchant for solving complex mathematical problems,
there are three feasible methods for attacking the problem. The
first is to pick a number (based either upon your liking for
indulging in Russian roulette, or upon recommendations from
friends or the DOS reference manual) and put your trust in the
tooth fairy as to the appropriateness of the number. The second
is to try to determine the number by systematic trial and error,
editing your CONFIG.SYS file over a period of time. The third
method is to set up an automatic process which can sweep through
a series of values, perform a realistic test with each value, and
record the results for later analysis.
The DISKBUF program permits this third approach to be taken
easily. After using DISKBUF, you can readily determine the op-
timum number of buffers to be used, based not only upon time to
perform the test but also upon the amount of RAM occupied by the
buffers. You can decide, and have some rational basis for the
decision, whether you are willing to sacrifice X bytes of addi-
tional RAM in order to gain an additional Y% performance improve-
ment from your disk operations.
Sure beats flying by the seat of the pants, no?
HOW DO I USE DISKBUF?
Four files are included in the file DISKBUF.ARC. They are,
DISKBUF.DOC (This file)
DISKBUF.COM (The operational program)
AUTOEXEC.BAT (A specimen AUTOEXEC file)
PLOTBUF.COM (A program to produce a screen
plot of the test results.
Duplicates code contained in
Examine the AUTOEXEC.BAT file. You will see, as the last
line of the file, the line invoking DISKBUF. In the REMark lines
preceding this, you will see guidelines for setting the switch
values to be passed to DISKBUF. The switches are:
/TARGET: (Sets the disk to be tested)
/MAXBUF: (Sets the stopping point for the
/MINBUF: (Sets the starting point for the
/PLOT (If present, a screen plot of the
test results will be produced)
The first two switches, /TARGET: and /MAXBUF: are required;
the other two, /MINBUF: and /PLOT are optional.
/TARGET:xx takes as an argument a valid disk device
designator, with the appended colon being optional. This deter-
mines the device which is to be tested. (Required)
/MAXBUF:nn takes as an argument an integer between 1 and
99, and determines the greatest number of buffers to be used in
the test. (Required)
/MINBUF:nn also takes as an argument an integer between
1 and 99, and determines the starting number of buffers to be
used in the test. If this switch is omitted, a starting value of
3 will be used. (Optional)
/PLOT determines by its presence or absence whether
or not a screen plot of the test results will be produced at the
completion of the test. NOTE: If your computer does not have a
graphics card, this switch must not be included! (Optional)
To use DISKBUF, four steps are required.
STEP 1. Format a disk using the /S switch to make the disk
STEP 2. Edit the AUTOEXEC.BAT file, to invoke DISKBUF with
the switch settings you want to be used.
STEP 3. Copy the edited AUTOEXEC.BAT file and the program
file DISKBUF.COM onto the disk prepared at Step 1.
STEP 4. Re-boot your computer.
STEP 5. Go to lunch, and come back in an hour or so.
When the test is completed, two new files will be on the
BUFFERS.RPT contains the test results, giving for
each number of buffers tested a figure
of merit and the minimum requirement
of RAM (in bytes) for DOS.
BUFFERS.PLT contains information used by the
program PLOTBUF.COM. Specifically,
each line contains the number of buff-
ers tested and the figure of merit.
The figure of merit for a given number of buffers is propor-
tional to the time required for the test. Thus, SMALLER is
BETTER. The minimum figure of merit is the one you want (ignoring
the amount of space occupied by the buffers).
Note that, if /PLOT was selected, the screen plot only dis-
plays a limited range of the figure of merit values. Specific-
ally, the range displayed is from the minimum figure of merit to
5% greater than this value. All figures of merit greater than
this are clipped at this level for plotting purposes.
This was done in order to better present the detail of the
values only slightly worse than the minimum value.
The screen plot may be recreated at any time by running
PLOTBUF. The only restriction is that the file BUFFERS.PLT must
be in the current disk and directory.
Should you wish to test against two different disks, the
files BUFFERS.* must be copied or renamed before the second test
is conducted. If this is not done, the files will be over-written
and the results of the earlier test will therefore be lost.
HOW DOES DISKBUF DO ALL THAT GOOD STUFF?
When DISKBUF is invoked, it performs the following
STEP 0. Read and parse command tail. Set operating par-
ameters, based on the contents of the command tail.
STEP 1. Check for the presence of the file CONFIG.SYS on
the default disk.
STEP 1A. If present, read it to extract the current
STEP 1A1. If this setting is not between MINBUF
and MAXBUF then re-write CONFIG.SYS with a
BUFFERS= setting equal to the value of MINBUF,
and go to STEP 1C.
STEP 1A2. If the setting is between MINBUF and
MAXBUF then go to STEP 2.
STEP 1B. If not present, create it with a BUFFERS=
setting equal to the value of MINBUF.
STEP 1C. Delete the BUFFERS.* files if they are pres-
ent, and re-boot the system.
STEP 2. Start the timer. Create a file in the root direct-
ory of the disk to be tested, containing 1000 records of 100
STEP 3. Perform the EXCHANGE test, by interchanging
records 1 and 1000, 2 and 999,...,500 and 501.
STEP 4. Perform the SHUFFLE test, by interchanging records
1 and 2, 2 and 3,...,999 and 1000. Stop the timer.
STEP 5. Calculate the figure of merit, and append a record
to BUFFERS.RPT. If /PLOT then append a record to
STEP 6. Check the current setting of BUFFERS= against the
value of MAXBUF.
STEP 6A. If buffer setting < MAXBUF, overwrite the
existing CONFIG.SYS file, incrementing the buffer set-
ting and re-boot the system.
STEP 6B. Otherwise, the test is completed.
STEP 6B1. Delete the test file from the root dir-
ectory of the disk being tested. Delete CONFIG.SYS
from the default disk.
STEP 6B2. If /PLOT is selected, plot the test
STEP 6B3. Exit to DOS.