previous next top contents index framed top this page unframed
14.1. Overview
The file cache (described in detail in
Section 22.16 of the MAINSAIL Language Manual)
is an optimization for random access
device MODULEs.
Its purpose is to improve I/O performance for files
opened for random access. The file cache
maintains a buffer cache that is
a linked list of buffers.
All files opened for random access can share the global file cache. In addition, files can be privately cached; however, private file caches can be manipulated only from a program.
When a device MODULE makes a request for a buffer, the file cache is searched. If the buffer is found, it is returned; otherwise a new buffer is read. Thus, an I/O operation is eliminated for every buffer request satisfied by the file cache. This significantly improves performance on I/O-bound machines. For example, the MAINSAIL compiler running on one system showed a 5-to-1 improvement in wall clock performance with the caching disk MODULE.
Maintenance of the cache is governed by three parameters: the minimum number of buffers in the file cache (requestedMinSize), the maximum number of buffers in the file cache (requestedMaxSize), and the file cache hit percentage to be maintained (requestedHitPercent). Buffers are added to the file cache as necessary until requestedMinSize buffers exist, after which the hit percentage governs further addition of buffers. Each time a request is made for a non-resident buffer, the actual hit percentage is compared with requestedHitPercent. If the actual hit percentage is less than requestedHitPercent (minus five percent) and the number of buffers is less than requestedMaxSize, a new buffer is created. The current buffer is added to the cache, making it larger. If the number of buffers is between requestedMinSize and requestedMaxSize and the actual hit percentage is greater than requestedHitPercent (minus five percent), the least recently accessed buffer is removed from the cache, written if necessary, and returned as empty. Again, the current buffer is added to the list, but since one has been removed, the file cache size remains constant.
XIDAK reserves the right to change the implementation of the file
cache without notice.
GCCHP (“Global CaCHe Parameters”)
allows you to set the global
file cache
parameters from the MAINSAIL executive.
When invoked, it displays the
current file cache parameters, the actual hit percentage, and the
maximum number of buffers that have been allocated for the file cache,
and then prompts for new values.
Example 14–1 illustrates how GCCHP may be used.
The global file
cache parameters are first changed so that the minimum number of buffers
is 30, the maximum number of buffers is 256, and the hit percentage is
100. The compiler, which opens random access files, is then run and
GCCHP is invoked again to display
the actual hit percentage and maximum
number of buffers allocated for the file cache. The current global
file cache
parameters remain unchanged.
14.2. How to Use GCCHP
The file cache is automatically used for all random access files. The
default values for requestedMinSize, requestedMaxSize, and
requestedHitPercent are operating-system-dependent.
MAINSAIL (R) Version 16.20.<release> (? for help)
Revision: <date>
Copyright (c) 1984-1998 by XIDAK, Inc., Point Arena,
California, USA.
*gcchp<eol>
Current global cache parameter values:
requestedMinSize: 8
requestedMaxSize: 128
size: 0
requestedHitPercent: 95
hit percent: 6
Want to specify new parms (Yes or No): y<eol>
New requestedMinSize (8): 30<eol>
New requestedMaxSize (128): 256<eol>
New hit percent (95): 100<eol>
*compil<eol>
MAINSAIL (R) Compiler
Copyright (c) 1984-1998 by XIDAK, Inc., Point Arena,
California, USA.
compile (? for help): sample.msl<eol>
Opening intmod for $SYS...
sample.msl 1 ...
Objmod for SAMPLE on sample-os.obj
Intmod for SAMPLE not stored
compile (? for help): <eol>
*gcchp<eol>
Current global cache parameter values:
requestedMinSize: 30
requestedMaxSize: 256
size: 30
requestedHitPercent: 100
hit percent: 80
Want to specify new parms (Yes or No): n<eol>
MAINSAIL Utilities User's Guide, Chapter 14