intel - 如何将英特尔 PCM 数据缩小到单个进程?
问题描述
我正在尝试使用英特尔性能计数器监视器 (PCM) 来了解我的代码中的 L3 缓存未命中和其他一些性能标准。
我不确定如何从我得到的数字中理解并希望得到一些见解。
理想情况下,我希望从以下代码中读取 0 个字节,但是我得到的数字接近 240KB 读取。如果我尝试运行其他进程,240KB 的数字会波动(不会单调上升/下降,它只是有有意义的波动(先上升然后下降))。
volatile SystemCounterState before_sstate = getSystemCounterState();
volatile SystemCounterState after_sstate = getSystemCounterState();
cout << "Instructions per clock: " << getIPC( before_sstate, after_sstate )
<< ", L3 Cache hit ratio: " << getL3CacheHitRatio( before_sstate, after_sstate )
<< ", L3 Missed Cycles: " << getCyclesLostDueL3CacheMisses(before_sstate, after_sstate )
<< ", Bytes read: " << getBytesReadFromMC( before_sstate, after_sstate )
<< ", L3 Occupancy: " << getL3CacheOccupancy( after_sstate ) << endl;
这是我得到的输出:
尝试使用 Linux 性能事件...
使用 Linux perf 成功编程核心 PMU
每时钟指令数:0.637448,L3 缓存命中率:0.820139,错过周期:0.075492,读取字节数:263488,L3 占用率:0
有谁知道为什么我读取了 240KB,尽管我实际上没有读取代码中的任何内容?它是否与其他进程共享计算资源并可能从其他进程中捕获统计信息?如果是这种情况,我如何确保捕获的信息与正在运行的代码/进程隔离?
解决方案
推荐阅读
- go - Go 如何保证内存安全?
- r - 在 R 中的数据框中选择第一行并在 group_by 中聚合
- swiftui - 在 SwiftUI 中点击手势时无法显示视图
- python - AttributeError:“响应”对象没有“读取”属性。使用请求和 jsons
- excel - 当目标值更改源自公式时更新 VBA 代码
- reactjs - 使用 React Hooks 的条件
- node.js - 如何使用 Apollo 分离 GraphQL 模式和解析器文件?
- arrays - Swift - 创建一个混合值数组
- html - 做元素有预设宽度?
- html - 在 Chrome 中强制跨 CSS 列分布图像