程序的大小如何增加高速缓存未命中率? [英] How can a program's size increase the rate of cache misses?

查看:131
本文介绍了程序的大小如何增加高速缓存未命中率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Wikipedia在其循环展开"文章中具有以下声明:

Wikipedia has the following statement in its Loop Unrolling article:

增加程序代码的大小,这是不希望的,尤其是对于嵌入式应用程序.还会导致指令高速缓存未命中率的增加,这可能会对性能产生不利影响.

Increased program code size, which can be undesirable, particularly for embedded applications. Can also cause an increase in instruction cache misses, which may adversely affect performance.

这是为什么?

还有,由于大量的死代码导致程序的代码大小变大,因为不执行死代码会不会增加高速缓存未命中率?

Also, having a program's code size be larger due to large amounts of dead code won't increase the rate of cache misses, since dead code won't be executed?

推荐答案

代码通常会在整个缓存行中读取到缓存中,该行可能为64、128或256个字节.如果您有一个256字节的高速缓存行,其中四分之三是无效代码,则说明您的高速缓存使用得不是很好.另一方面,如果您有兆字节的完全未使用的代码,则根本不影响缓存效率.

Code is typically read into caches in whole cache lines, which might be 64, 128 or 256 bytes. If you have a 256 byte cache line and three quarters of that is dead code, then you are not using your cache memory very well. On the other hand, if you have a megabyte of completely unused code, that doesn't affect cache efficiency at all.

某些编译器将使用启发式方法或软件开发人员的提示来找出可能很少使用的代码,并安排代码,以便一个缓存行将完全用过的代码填充或完全用未使用的代码填充.

Some compilers will use heuristics or hints by the software developer to find out which code is probably very rarely used, and arrange code so that one cache line will be completely filled with used code or completely filled with unused code.

与死代码不同,通过循环展开膨胀的已使用代码将增加缓存未命中率.

And unlike dead code, used code that is inflated by loop unrolling will increase cache misses.

这篇关于程序的大小如何增加高速缓存未命中率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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