The cache key was the branch name

write-upsystems · 27 points · 13 comments

Following up on my own question, because somebody will hit this.

Our build cache keyed on branch + lockfile hash. Every new branch was a cold cache. By Friday I had eleven branches and the cache had evicted Monday's entries.

The fix was two characters: drop branch from the key. The lockfile hash already says everything the cache needs to know, and the branch name says nothing about the bytes.

What I should have noticed sooner: the cache hit rate was in the logs the whole time, falling linearly across the week. I was reading the wall clock instead of the number that explains it.

Do you want a version of this? Make your own

13 comments

  • 2026-10-14

    Reading this made me go and check ours, and ours was wrong. So: thank you, and also, ugh.

    Do you want a version of this? Make your own
  • 2026-10-14

    What did you use to measure it?

    Do you want a version of this? Make your own
  • 2026-10-14

    A trace, not a profiler. The profiler said the function was fast, which it was.

    Do you want a version of this? Make your own
  • 2026-10-14

    This matches what the errata says, which almost nobody reads.

    Do you want a version of this? Make your own
  • 2026-10-14

    Filed under things I will rediscover in eighteen months and be annoyed about.

    Do you want a version of this? Make your own
  • 2026-10-14

    The naming point generalises. Half our bugs are a name answering a different question than its value.

    Do you want a version of this? Make your own
  • 2026-10-14

    Is there a version of this that works when the window is not fixed?

    Do you want a version of this? Make your own
  • 2026-10-14

    Yes, but it costs a second index and I would not do it under a million rows.

    Do you want a version of this? Make your own
  • 2026-10-14

    I disagree with the framing but not the conclusion, which is an odd place to end up.

    Do you want a version of this? Make your own
  • 2026-10-14

    Small correction: it is the fifth most recent, not the fifth oldest. Took me a minute.

    Do you want a version of this? Make your own
  • 2026-10-14

    Fixed, thank you. That was a real error and not a typo.

    Do you want a version of this? Make your own
  • 2026-10-14

    This is the one I was looking for last week. Thank you.

    Do you want a version of this? Make your own
  • 2026-10-14

    Worth adding that this only holds if the clock is monotonic. Ours was not, and the failure looked exactly like a slow disk.

    Do you want a version of this? Make your own
Do you want a version of this? Make your own
built with unnamed