In an $\alpha$-way set-associative cache, the cache is partitioned into disjoint sets of size $\alpha$, and each item can only be cached in one set, typically selected via a hash function. Set-associative caches are widely used and have many benefits, e.g., in terms of latency or concurrency, over fully associative caches, but they often incur more cache misses. As the set size $\alpha$ decreases, the benefits increase, but the paging costs worsen. In this paper we characterize the performance of an $\alpha$-way set-associative LRU cache of total size $k$, as a function of $\alpha = \alpha(k)$. We prove the following, assuming that sets are selected using a fully random hash function: - For $\alpha = \omega(\log k)$, the paging cost of an $\alpha$-way set-associative LRU cache is within additive $O(1)$ of that a fully-associative LRU cache of size $(1-o(1))k$, with probability $1 - 1/\operatorname{poly}(k)$, for all request sequences of length $\operatorname{poly}(k)$. - For $\alpha = o(\log k)$, and for all $c = O(1)$ and $r = O(1)$, the paging cost of an $\alpha$-way set-associative LRU cache is not within a factor $c$ of that a fully-associative LRU cache of size $k/r$, for some request sequence of length $O(k^{1.01})$. - For $\alpha = \omega(\log k)$, if the hash function can be occasionally changed, the paging cost of an $\alpha$-way set-associative LRU cache is within a factor $1 + o(1)$ of that a fully-associative LRU cache of size $(1-o(1))k$, with probability $1 - 1/\operatorname{poly}(k)$, for request sequences of arbitrary (e.g., super-polynomial) length. Some of our results generalize to other paging algorithms besides LRU, such as least-frequently used (LFU).
翻译:在$\alpha$路组相联缓存中,缓存被划分为大小为$\alpha$的不相交集合,每个项目只能被缓存在一个集合中(通常通过哈希函数选择)。组相联缓存被广泛使用,且相较于全相联缓存具有诸多优势(例如延迟或并发性方面),但通常会导致更多缓存缺失。随着组大小$\alpha$减小,优势增加,但分页开销恶化。本文刻画了总大小为$k$的$\alpha$路组相联LRU缓存的性能随$\alpha = \alpha(k)$变化的规律。假设使用完全随机哈希函数选择集合,我们证明以下结论:- 对于$\alpha = \omega(\log k)$,在长度为$\operatorname{poly}(k)$的所有请求序列上,$\alpha$路组相联LRU缓存的分页开销以概率$1 - 1/\operatorname{poly}(k)$不超过大小为$(1-o(1))k$的全相联LRU缓存分页开销的加性$O(1)$。- 对于$\alpha = o(\log k)$,对所有$c = O(1)$和$r = O(1)$,存在某个长度为$O(k^{1.01})$的请求序列,使得$\alpha$路组相联LRU缓存的分页开销不在大小为$k/r$的全相联LRU缓存分页开销的$c$倍以内。- 对于$\alpha = \omega(\log k)$,若哈希函数可偶尔更换,则对于任意长度(例如超多项式长度)的请求序列,$\alpha$路组相联LRU缓存的分页开销以概率$1 - 1/\operatorname{poly}(k)$不超过大小为$(1-o(1))k$的全相联LRU缓存分页开销的$1 + o(1)$倍。部分结果可推广至除LRU外的其他分页算法(如最不频繁使用(LFU)算法)。