TCS - ReadMe.1st -- Driving for Performance: RAMDrive and SMARTDrive

Driving for Performance:
RAMDrive and SMARTDrive

by Ken Johnson
Tulsa Computer Society
From the September 1997 issue of the I/O Port Newsletter

DOS and Windows have several ways to improve performance through the hardware, using programs called device drivers. Like their namesakes at the Daytona 500 or the Indy Speedway, a good driver can make your system fast. But you have to look out for bumps and curves on the course, because incorrect use of drivers can slow down performance, and at worse, a "spinout" can lose your work and damage files.

Two such drivers available in DOS and Windows 3.1 are RAMDrive (RAMDRIVE.SYS), for creating a RAM "disk" drive, and SMARTDrive (SMARTDRV.EXE), which caches information from disks. In the next few columns we'll look at how RAMDrive and SMARTDrive work, where they are best used (and best avoided), and how they compare performance-wise. And where they seemed to have disappeared to in Windows 95. This month we'll begin with RAMDrive.

RAMDRIVE.SYS is the DOS device driver that creates a "virtual" disk drive in memory. Called a RAM disk, it has a drive identifier (e.g., D:) and can be accessed just like a physical hard or floppy drive. A RAM disk improves performance because it is much, much faster to read and write information to memory than to a physical hard drive.

RAMDRIVE.SYS is loaded in CONFIG.SYS. It will set the drive letter of the RAM disk to the next available drive identifier. You'll need to look the first time you use RAMDrive to see the drive identifier; put a PAUSE command at the beginning of AUTOEXEC.BAT to prevent RAMDrive's message from scrolling off the screen. For a 1Mb RAM drive, you'll see something like:

Microsoft RAMDrive version 3.07 virtual disk D: Disk size: 1,024k
Sector size: 512 bytes
Allocation unit: 1 sector
Directory entries: 64

(Watch out though if you have a CD-ROM drive. Since RAMDRIVE.SYS loads before MSCDEX, it will very likely take the drive identifier for your CD-ROM, and the CD-ROM will take the next higher letter. You'll need to change the setup of your CD-ROM programs to look to that new drive identifier.)

The syntax for RAMDrive is:
DEVICE=[d:path]RAMDRIVE.SYS [disksize [sectorsize [dirsize]]] [/E | /A]
d:pathidentifies the location of the RAMDRIVE.SYS file (usually C:\DOS)
disksizethe size of RAM disk, in kilobytes. Valid values are 4 to 32767 (4K to 34Mb). The default if disksize is not specified is 64.
sectorsizethe size of the disk sectors in bytes. Valid values are 128, 256, 512, and 1024. Microsoft recommends 512. If you specify sectorsize, you must also specify disksize. (Note: the Windows 95 version of RAMDRIVE.SYS does not support sector sizes of 128 or 256.)
dirsizethe number of directory entries in the root directory of the RAM drive. Values are from 4 to 1024; the default is 64. If you specify dirsize, you must also specify disksize and sectorsize.
/Ecreates the RAM drive in extended memory.
/Acreates the RAM drive in expanded memory.

A RAM drive can be created in conventional, extended, or expanded memory. The most efficient RAM disk is in extended memory. Don't put a RAM disk in conventional memory; you're taking away precious memory below 640K that your applications need. Also don't use Expanded memory unless you have a true expanded memory board on your PC. If you use EMM386 to provide expanded memory, EMM386 is actually creating expanded memory out of extended memory. And because access to that expanded memory requires paging through the page frame, your losing some of the performance of having a RAM disk in the first place.

Using a RAM drive can speed up performance, but also poses several potential headaches. The most obvious is that when the power is lost, so is all the data in the RAM disk. Because of this, you have to remember to copy files from the RAM drive back to your hard disk (or floppy) before shutting down your computer. If you freeze and have to reboot, everything in the RAM drive is lost. In addition, if you want to access files from the RAM drive (such as program overlay files), you have to copy them to the RAM disk each time you boot your computer.

Because of the potential for data loss, using a RAM disk for data files is risky. However, there is an ideal use for a RAM drive that gives a performance boost with little danger: as storage for DOS and Windows' temporary files (*.TMP). Many of these temporary files are created while you're working on your computer (especially in Windows), and reading and writing them to memory is much faster than to the hard drive. For example, Windows' Print Manager "spools" out temporary files while printing; putting these on a RAM drive will significantly speed up large print jobs.

DOS and Windows determine which drive and directory to use for their temporary files through the TEMP (or TMP) environment variable. If you have sufficient memory, create a RAM drive in extended memory then point the TEMP variable to that drive.

For example, in CONFIG.SYS create a two megabyte RAM drive in extended memory with:

Since this command requires extended memory, make sure to put this line after the line that loads HIMEM.SYS (or your extended memory manager). When loaded, we see that the RAM drive is designated as the D: drive. Now in AUTOEXEC.BAT, include the line:

The default RAMDrive size is 64K, which is much too low for Windows and its temporary files, particularly for Print Manager. The RAM disk should be at least 2Mb. If there isn't enough RAM disk space for Print Manger, your print jobs may be corrupted in memory and the printouts unusable. Also, if an application program gives an "out of disk space" message, it might be out of TEMP RAM disk space. Try increasing the size of the RAM drive.

Another advantage of putting temporary files on a RAM disk is that they will be automatically deleted when you have a problem and reboot. Normally temporary files are deleted when you exit Windows normally, but not if you reboot or shut off the computer still in Windows. In those cases, if you use the hard drive for the TEMP directory, these temporary files will take up space until you manually delete them. (Check your TEMP directory and you may find a bunch of disk space you can reclaim!)

Speaking of deleting temporary files, if you are using Delete Sentry or Delete Tracking, don't protect the RAM drive. There is no reason to save undelete information about files you'll never want to undelete.

Don't try to use a RAM drive for your Windows 3.1 swap file. This is self-defeating exercise. You are sacrificing physical memory to provide a place to create virtual memory to replace the physical memory you just used to create the RAM disk! Windows won't even let you try to use a RAM drive. If you go into Control Panel, 386 Enhanced, then Virtual Memory, Windows will not display a RAM drive in the list of choices. (But if you have more than one hard drive, you can get a swap file performance boost by putting the swap file on the fastest hard disk on your system.)

RAMDrive appears to have "gone missing" in Windows 95. It isn't in \WINDOWS\COMMAND with the other DOS 7 commands, and if you installed WIN95 on an existing WIN31/DOS computer, RAMDRIVE.SYS is deleted from your \DOS directory. Yet if you look hard, you'll find the file in the \WINDOWS directory.

It certainly appears Microsoft doesn't want you to use RAMDrive in Windows 95. Glance at the 1300+ page Windows 95 Resource Kit from Microsoft -- there is no index listing for RAM drive or RAMDRIVE.SYS. With Windows 95 the operating system configures memory for optimal performance, meaning you no longer have to.

You can still set up a RAM disk in Windows 95 by loading C:\WINDOWS\RAMDRIVE.SYS in CONFIG.SYS, much as you did in DOS or Windows 3.1, and point temporary files to it with the TEMP variable. However, there are a few issues with using RAMDRIVE.SYS in Windows 95 to be aware of; it may simply be easier not to bother with a RAM disk and let Windows 95 do its own performance optimization.

Although theoretically you can create a RAM drive up to 32Mb, Windows 95 may not load if you have a RAM drive larger than 15Mb. You'll receive a "Not enough extended memory available to run Windows" error. The problem is a RAM drive larger than 15Mb takes all extended memory addresses below 16K; Windows 95 needs 4K of that for its DMA buffers, and cannot start if all 16Mb is allocated. You must lower the value on the RAMDRIVE.SYS command line to below 15Mb.

Another quirk of the RAMDRIVE.SYS included with Windows 95 is that it does not support sector sizes of 128 or 256 bytes. Using those sector sizes will produce an "Incompatible Parameters: Sector Size Adjusted" error, and the sector size is set to 512 bytes. Microsoft's suggested workaround to this problem is to use a RAMDRIVE.SYS from an earlier DOS version, and updating and loading SETVER to tell Windows 95 the version.

If you are still a DOS or Windows 3.1 user, you can get significant performance improvements if you have sufficient extended memory, by setting up a RAM disk with RAMDrive and using it to store temporary files. Windows 95 users generally don't have to deal with a RAM drive. Though you can load RAMDRIVE.SYS, most of us can leave this high performance driving to Windows 95 itself.

Next month we'll look at another performance enhancer -- disk caching with SMARTDrive.

Kenneth E. Johnson is author of "The Lawyer's Guide to Creating Web Pages," published by the American Bar Association, and is currently working on a book on E-mail. He is Assistant Editor of the ABA's Network 2d newsletter, and Contributing Editor of Practical Windows and DOS World Magazines.

For more information on the Tulsa Computer Society click here

This page has been accessed times.
Tulsa Computer Society 08/15/97
Don Singleton, President