



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Cache Performance Equation
System Performance. To correctly evaluate cache performance, we must examine the effect of cache on overall system performance rather than trying to optimize the cache per- formance by itself. Recall that over system performance is measured by total program execution time.
i
We will assume that the pipeline is designed not to stall on a cache hit. Since the L1 cache must provide instructions or data every clock period, the L1 cache access time must be less than one clock period.
A cache miss would require stalling until the cache can respond. The number of stall cycles required is called the cache miss penalty, Tmiss-penalty. The cache miss penalty can
be quite different for reading and writing. For example, if we use write around (no-fetch- on-write-miss), there is no write miss penalty as long as there is room in the write buffer.
Cache misses occur at a rate that depends on the program being run and the design details of the cache. Note that larger caches have lower miss rates.
Lets define
where CPIexecution includes effects of all stalls except cache misses, and SPImiss includes
stalls due to cache misses only. Then
i
which is a more accurate version of the equation in the middle of p. 492.
The evaluation of cache performance depends on the details of the hardware configura- tion. If we assume a separate instruction cache and data cache, we can find the cache miss stalls per instruction for each instruction type as
data-miss
data-miss
where Pinstruction-miss is the instruction cache miss rate (miss probability) Pdata-miss is the data cache miss rate (miss probability) Tread-miss-penalty is the instruction miss and read data miss penalty (in clock cycles) Twrite-miss-penalty is the write data miss penalty (in clock cycles) RPI i is the number of data reads per instruction (1 for loads, 0 otherwise); WPI i is the number of data writes per instruction (1 for stores, 0 otherwise); which is a more exact version of the equation on the top of p. 493.
Rewriting the performance measures by completing the summation over the instruction types, i , gives
where
i
i
data-miss
data-miss
The above formulas are for separate data and instruction cache. It applies equally well for a single unified instruction and data cache. In this case, CPIexecution is larger because of
the stalls necessary to avoid the structural hazard caused by contention for the memory by load and store instructions. Even when instruction cache and data cache are the same cache, Pinstruction-miss < Pdata-miss because of the higher locality of reference for instruc-
tions.
The miss rates (probabilities), Pinstruction-miss and Pdata-miss, have been written as indepen- dent of the instruction type index, i. This is because a miss occurs when an instruction is
the CPU. The hit time of top level cache is usually more important since it is incorporated into the CPU pipeline and has an effect on the CPU pipeline clock period and number of pipeline stages. The average access time includes the amount of time that the processor is stalled during the miss penalty and it determines the overall performance of the memory but does not determine the pipeline clock period.
The miss penalty is usually about 10 to 100 times the hit time.
This gives an average access time
Tmem as a function of Pmiss is shown below.
Pmiss Tmem 0.1 2.0 Thit < Tmem < 11.0 Thit 0.01 1.1 Thit < Tmem < 2.0 Thit
To get the average access time, Tmem, within a factor of 2 of the ideal cache memory per-
formance, Thit, requires Pmiss < 1% to 10%. Very low miss rates (high hit rates) are
needed to get the performance benefits of cache memory.
Choosing Cache Design Parameters
We must now try to design a cache that is going to have the very high hit rate required for high system speed. Unfortunately, it is difficult to predict what the cache performance will be for any particular application program since the performance is highly dependent on the sequence of addresses actually generated by running the application. We will use the results from the benchmark program, but remember that the actual performance for any other program will be different.
The cache design parameters that we consider are
Cache Size. Increasing cache size reduces the miss rate (good) but also increases the hit time (bad). Since hit time must be as short as possible for top level cache, large on chip cache is usually not a good choice. Otherwise, the increase in the hit time is a small price to pay for the reduced miss rate.
Different results are obtained for an instruction cache and a data cache running the same benchmark programs. The greater degree of sequentiality in the instruction addresses makes even a very small instruction cache highly effective. A larger cache is needed for data to get the same performance.
The general trend is that increasing the cache size always gives some improvement in the miss rate, as shown in fig. 7.31, p. 544. However, the amount of improvement decreases as the cache gets larger (the law of diminishing returns strikes again).
Economic considerations usually limit the size of cache. When the cache is large enough so that performance improvements are minimal, we are less willing to pay the cost of increasing the size of cache.
To understand the effect of cache size on miss rate, it helps to break down the misses into the three categories on p. 543.
- compulsory miss - an infinite size cache has only these misses. - capacity miss - additional misses from a finite size, fully associative cache. - conflict miss - additional misses caused by mapping.
Pmiss
size
direct mapped
fully associative
compulsory misses
capacity misses
conflict misses
Cache size cannot reduce compulsory misses; thus, it would not pay to increase cache size beyond the point where most of the misses are compulsory.
Block Size. The number of compulsory misses is reduced by bigger block sizes since it is more likely that an address, when it is first referenced, will have already been read in on a previous miss on an address in the same block.
Unfortunately, a smaller number of large blocks will fit into a fixed cache size. A smaller number of blocks leads to an increase in capacity and conflict misses. The increase in capacity and conflict misses eventually swamps the reduced compulsory misses when the block size gets large. See fig. 7.8, p. 481.
Increasing the block size can also increases the miss penalty. Recall that the primary con- tribution to the miss penalty is the fill time.