被用在实际的CPU缓存什么缓存失效算法? [英] What cache invalidation algorithms are used in actual CPU caches?

查看:291
本文介绍了被用在实际的CPU缓存什么缓存失效算法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我来到了话题缓存和映射和高速缓存未命中以及如何缓存块被替换以什么顺序时,所有块都已经满了。

I came to the topic caching and mapping and cache misses and how the cache blocks get replaced in what order when all blocks are already full.

有最近最少使用算法或FIFO算法或至少经常算法和随机替换,...​​

There is the least recently used algorithm or the fifo algorithm or the least frequently algorithm and random replacement, ...

但什么算法用于实际的CPU高速缓存?或者,你可以使用所有的...操作系统决定最好的算法是什么?

But what algorithms are used on actual cpu caches? Or can you use all and the... operating system decides what the best algorithm is?

编辑:即使我选择的答案,任何进一步的信息是值得欢迎的;)

Even when i chose an answer, any further information is welcome ;)

推荐答案

由于HIVERT说 - 这是很难得到具体的算法一清二楚,但我们可以根据提示或聪明的逆向工程推断出一些信息。

As hivert said - it's hard to get a clear picture on the specific algorithm, but one can deduce some of the information according to hints or clever reverse engineering.

您没有指定哪些CPU你的意思是,每个人可以有不同的策略(实际上即使在相同的CPU不同的缓存级别可能有不同的政策,更不用提的TLB和其他关联数组也可能有这样的政策) 。我没有找到有关英特尔(特别是Ivy Bridge的)一些提示,所以我们将以此为基准,行业水平的标准(这可能会或可能不会在其他地方申请)。

You didn't specify which CPU you mean, each one can have a different policy (actually even within the same CPU different cache levels may have different policies, not to mention TLBs and other associative arrays which also may have such policies). I did find a few hints about Intel (specifically Ivy bridge), so we'll use this as a benchmark for industry level "standards" (which may or may not apply elsewhere).

首先,英特尔presented一些LRU相关的功能在这里 - <一href="http://www.hotchips.org/wp-content/uploads/hc_archives/hc24/HC24-1-Microprocessor/HC24.28.117-HotChips_IvyBridge_Power_04.pdf">http://www.hotchips.org/wp-content/uploads/hc_archives/hc24/HC24-1-Microprocessor/HC24.28.117-HotChips_IvyBridge_Power_04.pdf

First, Intel presented some LRU related features here - http://www.hotchips.org/wp-content/uploads/hc_archives/hc24/HC24-1-Microprocessor/HC24.28.117-HotChips_IvyBridge_Power_04.pdf

46滑动提到的四时代LRU - 这显然是基于LRU的时代,根据其predicted重要性赋予一定年龄在每一行。他们提到prefetches得到中年,所以要求也可能分配以较高年龄(或更低,无论最长生存),以及所有可能的线年龄逐渐的,所以最老被替换第一。还不如完善先进先出样LRU,但请记住,大多数缓存没有实现这些,而是​​一个复杂的伪LRU 的解决方案,因此,这可能是一种进步。

Slide 46 mentioned "Quad-Age LRU" - this is apparently an age based LRU that assigned some "age" to each line according to its predicted importance. They mention that prefetches get middle age, so demands are probably allocated at a higher age (or lower, whatever survives longest), and all lines likely age gradually, so the oldest gets replaced first. Not as good as perfect "fifo-like" LRU, but keep in mind that most caches don't implement that, but rather a complicated pseudo-LRU solution, so this might be an improvement.

提到有另一个有趣的机制,这更是不辞辛劳超越经典的LRU,是自适应的补政策。有一个pretty的好位置分析 - <一个href="http://blog.stuffedcow.net/2013/01/ivb-cache-replacement/">http://blog.stuffedcow.net/2013/01/ivb-cache-replacement/ ,但简而言之(如果博客是正确的,而且他似乎有一个良好的比赛与他的结果),在二级缓存LRU政策之间动态选择,试图决定该行是否将要被重复使用或没有(应保持与否)。

Another interesting mechanism mentioned there, which goes the extra mile beyond classic LRU, is adaptive fill policy. There's a pretty good analysis here - http://blog.stuffedcow.net/2013/01/ivb-cache-replacement/ , but in a nutshell (if the blog is correct, and he does seem to make a good match with his results), the cache dynamically chooses between two LRU policies, trying to decide whether the lines are going to be reused or not (and should be kept or not).

我想这可能会在多个LRU方案回答在一定程度上你的问题。实施几种方案可能很难和昂贵的硬件方面,但是当你有一个:有点复杂,足有参数的一些政策,有可能使用小把戏,比如动态选择,设置决斗等。

I guess this could answer to some extent your question on multiple LRU schemes. Implementing several schemes is probably hard and expensive in terms of HW, but when you have some policy that's complicated enough to have parameters, it's possible to use tricks like dynamic selection, set dueling , etc..

这篇关于被用在实际的CPU缓存什么缓存失效算法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆