Linux perf命令以获取缓存参考 [英] Linux perf command for cache references

查看:201
本文介绍了Linux perf命令以获取缓存参考的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想测量代码的缓存未命中率。我们可以使用性能列表来显示支持的事件。我的台式机具有3.10 GHz处理器的Intel®Core™i5-2400 CPU,性能列表中包含缓存刷新率和缓存丢失,例如:

I want to measure cache miss rate of my code. We can use perf list to show supported the events. My desktop has a Intel(R) Core(TM) i5-2400 CPU @ 3.10GHz processor, the perf list contains cache-refrences, and cache-misses, like this:

  cpu-cycles OR cycles                               [Hardware event]
  stalled-cycles-frontend OR idle-cycles-frontend    [Hardware event]
  stalled-cycles-backend OR idle-cycles-backend      [Hardware event]
  instructions                                       [Hardware event]
  cache-references                                   [Hardware event]
  cache-misses                                       [Hardware event]

我认为根据Intel体系结构软件开发人员手册,高速缓存未命中已映射到硬件事件LLC未命中(我通过比较 perf stat来确认这一点-e r412e perf stat -e cache-misses ,它们给出的结果几乎相同)。但是如何计算缓存引用?我没有找到使用现有硬件事件获取缓存总引用的事件或方法。所以我想知道此缓存引用在我的计算机上是否正确?

I think cache-misses is mapped to hardware event LLC-misses according to the Intel architectures software developer's manual (I confirm this by comparing perf stat -e r412e and perf stat -e cache-misses, they given almost identical result). But how is cache-references counted? I didn't find a event or way to get total cache references using existing hardware events. So I'm wondering if this cache-references is accurate on my computer?

推荐答案

在Intel上,我不认为 perf 提供了一个事件以衡量总缓存引用,因为此类事件在硬件级别上不存在。您应该能够使用性能列表报告的硬件缓存事件自己计算此信息:

On Intel, I don't think perf is providing an event to measure total cache references because such event doesn't exist at hardware level. You should be able to compute this information yourself using hardware cache event reported by perf list:

L1-dcache-loads                                    [Hardware cache event]
L1-dcache-load-misses                              [Hardware cache event]
L1-dcache-stores                                   [Hardware cache event]
L1-dcache-store-misses                             [Hardware cache event]
L1-dcache-prefetches                               [Hardware cache event]
L1-dcache-prefetch-misses                          [Hardware cache event]
L1-icache-loads                                    [Hardware cache event]
L1-icache-load-misses                              [Hardware cache event]
L1-icache-prefetches                               [Hardware cache event]
L1-icache-prefetch-misses                          [Hardware cache event]
LLC-loads                                          [Hardware cache event]
LLC-load-misses                                    [Hardware cache event]
LLC-stores                                         [Hardware cache event]
LLC-store-misses                                   [Hardware cache event]
LLC-prefetches                                     [Hardware cache event]
LLC-prefetch-misses                                [Hardware cache event]

没有事件标记有-未命中表示关联的缓存中的引用数。

Events not tagged with -misses represent the number of references in the associated cache.

注意:上一个问题和此有关perf_event_open(由perf内部使用)的手册页可能会有所帮助。

Note: this previous question and this man page about perf_event_open (used internally by perf) may help.

这篇关于Linux perf命令以获取缓存参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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