1. A method performed by data processing apparatus, the method comprising: placing a plurality of items into a cache, each item having a label based on metadata associated with the item; performing a number of accesses to respective items in the cache; determining a per-label stack distance histogram for each label, including, for each label, determining a plurality of stack distances for accesses to items having the label; and adjusting the cache using the per-label stack distance histograms.