Basis Lab

Keeping the Answer Nearby

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.

FIG 1What the cache actually saved, for two caches on the same traffic
stepwhat is being compareda cache on a slow reporta cache on a fast lookupthe multiplewhat happened
1hit rate40 per cent90 per cent2.25 times, in the fast lookup's favourThe number on the dashboard, and the only one of these four rows a counter hands you for nothing.
2hits, in the same 1,000 reads4009002.25 times, in the fast lookup's favour againThe read rate is the same in both columns, so the hits follow the hit rate exactly and nothing new has been learned yet.
3what one miss would have cost2 seconds0.1 milliseconds20,000 times, now the other wayThis 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.
4work avoided per 1,000 reads400 times 2 seconds, so 800 seconds900 times 0.1 milliseconds, so 0.09 secondsnearly 9,000 times, the other wayMultiply 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.
4 steps
Read the last row against the first and the two caches come out in opposite orders. Hit rates and read rates rarely differ between two caches by more than a factor of a few, while the cost of a miss differs by orders of magnitude, so the saving is decided by the row nobody puts on a dashboard.

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 contents

This 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

The rest of this course

  1. 01The Same Thing, Asked Again
  2. 02What You Actually Buy With a Hitopening only
  3. 03Choosing What to Forgetopening only
  4. 04When the Copy Stops Being Trueopening only
  5. 05Choosing How Far Away to Keep Itopening only
  6. 06The Ways a Cache Turns On Youopening only
  7. 07Many Boxes Pretending to Be Oneopening only
  8. 08Telling Whether It Earns Its Placeyou are here

Read alongside