I have went through various problems involving time required to access required data in the context of caching.

They use different formulae in different problems. For example, this answer suggests these formulae:

effective-access-time = hit-rate * cache-access-time
                  + miss-rate * lower-level-access-time  

effective-access-time = cache-access-time + miss-rate * miss-penalty

Let me rewrite them:

  1. $T_{eff}=H_{L1}\times T_{L1} + (1-H_{L1})\times T_{LowerLevelMemories}$
  2. $T_{eff}=T_{L1}+(1-H_{L1})\times T_{L1MissPenalty}$

$H_{L1}$ is L1 cache hit rate
$T_L1$ is L1 cache access time
$T_{LowerLevelMemories}$ is time to access lower level memories
$T_{L1MissPenalty}$ is L1 cache miss penalty

About when to use which formula, the answer says:

  • use first formula when lower level memory access time is given and
  • 2nd formula when miss penalty is given.

Is it so?

Let me put $T_{LowerLevelMemories}=T_M$, a main memory access time in formula 1. Also, I feel formula 1 ignores that we do indeed access L1 cache when cache miss occurs. So we should also multiply $(1-H_{L1})$ by $T_{L1}$. So formula 1 becomes:

$T_{eff}=H_{L1}\times T_{L1} + (1-H_{L1})\times (T_M+T_{L1})$ $=H_{L1}\times T_{L1} + T_M+T_{L1} -H_{L1}\times T_M-H_{L1}\times T_{L1}$
$=T_{L1}+(1-H_{L1})\times T_M$

This last equation resembles formula 2 above. Also we can interpret that $T_M$ is exactly the L1 miss penalty. So I feel, we should

  • use formula 2 when we assume L1 is accessed even during miss and
  • formula 1 when we assume L1 is not accessed during miss

However this does not align with what answer has to suggest as quoted above. Am I correct with how to make decision when to use which formula or the quoted suggestion from the answer is correct?

  • $\begingroup$ There is some interesting discussion in the comments section of the original answer which I feel are quite relevant to the doubts you are having. $\endgroup$ – ss09 Dec 26 '19 at 18:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.