[comp.sys.mac.programmer] Data caches

dekker_j@kosmos.wcc.govt.nz (06/19/91)

Consider this CPU sequence when data is required in a Mac IIci: 1 Look
for data in CPU's own cache, if not there; 2 Look in installed 128k
static ram cache, if not there; 3 Look in systems ram cache, if not
there; 4 Look on the hard disk.

Correct me if this sequence is wrong!

What would be the best size for the systems ram cache? Given that the
last 128k of data may reside in the static ram, is there any point in
having it set for more than the minimum 16k. Experience suggest yes
but why.

What advantage is there in having a static ram cache of more than 32k?
Will the CPU be slowed by having to look through a larger cache or is
the increased likelihood of finding data in a 128k static cache worth
the extra time required to look?

Dan.Richard%express@freedom.msfc.nasa.gov (Dan C. Richard) (06/21/91)

In article <1991Jun19.194615.4198@kosmos.wcc.govt.nz>, dekker_j@kosmos.wcc.govt.nz writes:
> 
> 
> Consider this CPU sequence when data is required in a Mac IIci: 1 Look
> for data in CPU's own cache, if not there; 2 Look in installed 128k
> static ram cache, if not there; 3 Look in systems ram cache, if not
> there; 4 Look on the hard disk.
> 
> Correct me if this sequence is wrong!
> 
> What would be the best size for the systems ram cache? Given that the
> last 128k of data may reside in the static ram, is there any point in
> having it set for more than the minimum 16k. Experience suggest yes
> but why.
> 
> What advantage is there in having a static ram cache of more than 32k?
> Will the CPU be slowed by having to look through a larger cache or is
> the increased likelihood of finding data in a 128k static cache worth
> the extra time required to look?
> 
> 
There are two (2) different caches!

1) A cache for CPU instruction & data feteches.
2) An optional DISK cache for disk (hard and floppy) accessing.

To use the Mac IIci case:
 a) the CPU has two caches: 256 bytes for insructions and 256 bytes for data
 b) the cache card caches both instructions and data.

The on chip cache takes 2 cycles to determin a hit but this operation can be 
overlapped with ongoing memory accessing. Remember the 68030 & 68040 are
Harvard architure machines with seperate data and instruction paths between
the two caches and the CPU.

With zero wait state memory, a memory operation takes 3 cycles. IF the memory
port IS IDLE, a the first 2 cycles of a memory access are started when the
query to on chip cache is made. IF a hit is found, the memory access is aborted!

IF there is NO on chip cache hit, the cache board is responding to the CPU.
The speed of the cache board depends on its design.

The only board I know well are the two for the Mac II (5 cycles access memory)
The Orchid Sprint board: 3 cycles on a hit, 6 on a miss.
Dove Racer: 3 cycles on a hit, 5 on a miss (but it flushed the cache on every
PMMU or FPU instruction!).

A good design would give the same performance independent of size of the
cache board. Since the Mac II, IIx, IIci, IIfx, IIsi all use logical
address (address befor PMMU translation), the cache must be flushed
(erased) at very important times (that is when the PMMU registers change
or after a DMA data transfer). This effect total performance.

Rule of thumb: The bigger the cach, the better. For most machines, 32K of 
cache give 90%+ hit rate. 256 byte cache give 30-40% hit rate!

And now for something completly different.

DISK cache.

The disk cache is to improve disk I/O performance.
Remember:

Computation proceed at the speed of light.
I/O proceeds at the speed of SOUND!
   -- Pacific Sierra course on programming Vector Processors

The larger the cache the the less offten you have to do disk I/O.
The Macintosh Tech note 81 on how disk caching works.

Disk caching is available on ANY Mac since the Mac Plus (and the OS released
with it).

CPU caching is hardware this is either build in the CPU (68020 (instructions onlY)
68030 (256 bytes of instruction and 256 of data ) and 68040 (4K of each) and
is available as addition cache on: Mac II (Orchid Sprint, Dove Racer),
IIci (many manufactures) and IIfx (32K with the Machine).