Created
May 29, 2015 18:46
-
-
Save zapman449/3cb1eabce2f07e67d9f1 to your computer and use it in GitHub Desktop.
Math of Cache Hit Ratios
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The formulas to generate the relevant values of Cache Hit ratios (and sundry): | |
The variables: | |
1. % is the cache hit ratio | |
2. H is the raw number of cache hits | |
3. M is the raw number of cache misses | |
4. T is the total number of requests. | |
The formulas: | |
'''% = H / T''' | |
Cache hit ratio is the number of hits divided by the total number of requests | |
'''H = T * %''' | |
The number of hits is the total number of hits multiplied by the cache hit ratio (.05 for a 5% cache hit ratio) | |
'''M = T - H''' | |
Misses is the total number of requests - the number of hits | |
'''T = M + H''' | |
Total number of requests is the number of misses + the number of hits. | |
Some of the above are obvious. But, what's interesting is that given the above formulas, some highschool algebra and time, | |
you can solve for any of the four, given any two of the others: | |
Given % and T (fairly obvious): | |
'''M = T * (T * %)''' | |
'''H = T * %''' | |
Given % and H (fairly obvious): | |
'''T = H / %''' | |
'''M = (H / %) - H''' | |
Given % and M (these are slightly tricky): | |
'''H = (% * M) / ( 1 - %)''' | |
'''T = ( (% * M) / (1 - %) ) + M''' | |
Given H and M (these are givens): | |
'''% = H / (H + M)''' | |
'''T = H + M''' | |
Given H and T (these are givens as well): | |
'''% = H / T''' | |
'''M = T - H''' | |
Given M and T (straightforward): | |
'''% = (T - M) / T''' | |
'''H = T - M''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment