A file system uses an in-memory cache to cache disk blocks. The miss rate of the cache is shown in the figure. The latency to read a block from the cache is 1 ms and to read a block from the disk is 10 ms. Assume that the cost of checking whether a block exists in the cache is negligible. Available cache sizes are in multiples of 10 MB.
The smallest cache size required to ensure an average read latency of less than 6 ms is _______ MB.
Explanation: When CPU needs to search for data, and finds it in cache, it’s called a HIT, else wise MISS. If data is not found in the ache, then CPU searches it in main memory.
Consider x to be MISS ratio, then (1-x) would be HIT ratio.
Whenever there is hit, latency is 1ms and 10ms upon miss.
Time to read from main memory(disk) for all misses = x * 10 ms
Time to read for all hits from cache = (1-x)*1 ms
Average time: 10x + 1 -x = 9x + 1
As asked in the question, average read latency should be less than 6 ms.
9x +1 < 6 9x < 5 x < 0.5556
For 20 MB, miss rate is 60% and for 30 MB, it is 40%. Thus, the smallest cache size required to ensure an average read latency of less than 6 ms is 30 MB.
Quiz of this Question