如何更改perf_event_open最大采样率 [英] how to change perf_event_open max sample rate

查看:905
本文介绍了如何更改perf_event_open最大采样率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用perf_event_open来获取样本.我尽力使每个人都切中要点.但是perf_event_open不够快.我尝试使用以下命令更改采样率:

I'm using perf_event_open to get samples. I try to get everyone hit of point. But perf_event_open is not fast enough. I try to change the sample rate using below command:

echo 10000000 > /proc/sys/kernel/perf_event_max_sample_rate

但是看起来我设置的值太大.运行我的代码后,将perf_event_max_sample_rate更改回较低的值,例如12500.当我尝试更改较大的值(例如20000000、50000000等)时,采样速度不会随着更改为我的值而增加.有什么方法可以更快地更改perf_event_open采样速度?

But it looks like the value I set was too large. After running my code, perf_event_max_sample_rate is change back to a lower value such as 12500. And when I try to change bigger value,for example 20000000,50000000 and so on, the sample speed is not increased as value I changed to. Is there any way to change perf_event_open sample speed more faster?

推荐答案

实际上不可能将perf_event_max_sample_rate增加到一定值之外.

It is really not possible to increase the perf_event_max_sample_rate beyond a certain value.

我尝试将其增加到100,000以上,例如说类似200,000之类的内容.每次执行此操作时,最大采样率总是降到 146,500个采样/秒或更低.如果我没记错的话,这是我可以达到的最大值(即 146,500个样本/秒).当然,这取决于您使用的机器类型和CPU频率等.我正在研究 Intel Xeon v-5 Broadwell CPU .

I have tried increasing it to above 100,000 , say for example something like a 200,000 or something more. Every time I did this, the max sample rate always came down to something like 146,500 samples/sec or less. If I recall correctly, this was the maximum I could achieve (i.e. 146,500 samples/sec). This would of course, depend on the kind of machine you are using and the CPU frequencies etc. I was working on an Intel Xeon v-5 Broadwell CPU.

祖兰很好.为了使您的理解更加清楚,性能样本集合是基于中断的.每次采样计数器溢出时,perf都会引发NM(不​​可屏蔽)中断.同时,此中断将计算实际处理整个中断过程所需的时间.您可以在下面的内核代码中看到它:-

Zulan makes a good point. To make your understanding clearer, the perf sample collection is based on interrupts. Every time the sampling counter overflows, perf would raise an NM(non-maskable) interrupt. This interrupt meanwhile will calculate the time it takes to actually handle the whole interrupt process. You can see this in the below kernel code :-

perf_event_nmi_handler

现在,一旦计算出处理中断的时间,它将调用另一个函数(将中断处理时间作为参数传递给该函数),在此函数将尝试检查当前的perf_event_max_sample_rate并将其与所需的时间进行比较.处理中断.如果发现中断花费了足够长的时间,同时又非常频繁地生成了样本,则由于中断工作开始排队,CPU显然将无法跟上,您将观察到一定数量的中断. CPU throttling.如果您看下面的功能,总会尝试减少样本量

Now once it has calculated the time for handling the interrupt, it calls another function (in which it passes the interrupt handling time as a parameter) where it tries to examine and compare the current perf_event_max_sample_rate with the time it takes to handle the interrupt. If it finds that the interrupt is taking a long enough time and at the same time, the samples are being generated very frequently, the CPU will obviously not be able to keep up as interrupt work starts getting queued up and you will observe some amount of CPU throttling. If you look at the below function, there will always be an attempt to reduce the sample

阅读以下功能以了解:-

Read the below function to understand :-

perf_event_sample_took

当然,正如Zulan所建议的那样,您可以尝试将其设置为0,但是您会从perf中获得相同的最大样本数,从而进一步损害CPU,除非您弄清楚其他数值,否则不可能增加该最大值.手段(如可能,调整缓冲区).

Of course, as Zulan suggested, you can try making it 0, but you would get the same maximum number of samples from perf and further hurt the CPU, it is not possible to increase the maximum unless you figure out other means (like tweaking the buffer if possible).

这篇关于如何更改perf_event_open最大采样率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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