Telling Whether It Earns Its Place
Last timeWhen There Is More Than One
The hit rate is the number everybody watches and the one that answers the fewest questions. What you want to know is what the cache saved, what it still fails to save, and what more of it would buy.
Every cache reports a hit rate, and it is the first number anybody looks at. It is also the number least able to answer the question people are asking, which is whether the cache is worth what it costs and what to do next.
What the hit rate leaves out
A hit rate counts events and weights them all the same. One hit on an answer that would have taken two seconds counts exactly as much as one hit on an answer that would have taken a tenth of a millisecond.
| step | what is being compared | a cache on a slow report | a cache on a fast lookup | the multiple | what happened |
|---|---|---|---|---|---|
| 1 | hit rate | 40 per cent | 90 per cent | 2.25 times, in the fast lookup's favour | The number on the dashboard, and the only one of these four rows a counter hands you for nothing. |
| 2 | hits, in the same 1,000 reads | 400 | 900 | 2.25 times, in the fast lookup's favour again | The read rate is the same in both columns, so the hits follow the hit rate exactly and nothing new has been learned yet. |
| 3 | what one miss would have cost | 2 seconds | 0.1 milliseconds | 20,000 times, now the other way | This is the factor a hit rate cannot see, and it is the one that varies by orders of magnitude between kinds of answer rather than by a factor of two. |
| 4 | work avoided per 1,000 reads | 400 times 2 seconds, so 800 seconds | 900 times 0.1 milliseconds, so 0.09 seconds | nearly 9,000 times, the other way | Multiply the two rows above and the ranking reverses: 800 seconds against 0.09. The cache people would call broken avoids four orders of magnitude more work than the one they would call healthy. |
So the measurement worth keeping is not the hit rate but the product. In practice that means recording, per kind of answer, how many hits it took and what a miss on it costs, and reporting the saving. A cache whose hits are all on expensive answers can be enormously valuable at a hit rate people would describe as broken.
The lesson stops here
4 more paragraphs to go
You have read the opening. The rest of the argument, the problems that check whether it landed, and the lines worth keeping at the end all come with a plan.
The first lesson of every course in the library reads the whole way through, free, so you can see exactly what the rest of them are.
See the planThe contentsThis is the reading half
Starting the course gives you your own copy of it. Every idea on every page has problems standing under it, marked with a reason rather than a tick, and any sentence you do not believe can be opened and argued with. None of that can happen on a page nobody owns.
The contents