当我们用perf去采样的时候,我们经常设置的频率是99,而不是100这样的频率,譬如:

# sudo perf record -F 99 -a -g -- sleep 20

[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.560 MB perf.data (~24472 samples) ]

Options are:

  • -F 99: sample at 99 Hertz (samples per second). I'll sometimes sample faster than this (up to 999 Hertz), but that also costs overhead. 99 Hertz should be negligible. Also, the value '99' and not '100' is to avoid lockstep sampling, which can produce skewed results.

上面的解释是设置为100,会引起lockstep采样。(上面一段话取自:

http://www.brendangregg.com/blog/2014-06-22/perf-cpu-sample.html)

那么,什么是lockstep采样呢?我们来看看https://stackoverflow.com/questions/45470758/what-is-lockstep-sampling

上面的回答:

Lockstep sampling is when the profiling samples occur at the same frequency as a loop in the application. The result of this would be that the sample often occurs at the same place in the loop, so it will think that that operation is the most common operation, and a likely bottleneck.

An analogy would be if you were trying to determine whether a road experiences congestion, and you sample it every 24 hours. That sample is likely to be in lock-step with traffic variation; if it's at 8am or 5pm, it will coincide with rush hour and conclude that the road is extremely busy; if it's at 3am it will conclude that there's practically no traffic at all.

For sampling to be accurate, it needs to avoid this. Ideally, the samples should be much more frequent than any cycles in the application, or at random intervals, so that the chance it occurs in any particular operation is proportional to the amount of time that operation takes. But this is often not feasible, so the next best thing is to use a sampling rate that doesn't coincide with the likely frequency of program cycles. If there are enough cycles in the program, this should ensure that the samples take place at many different offsets from the beginning of each cycle.

To relate this to the above analogy, sampling every 23 hours or at random times each day will cause the samples to eventually encounter all times of the day; every 23-day cycle of samples will include all hours of the day. This produces a more complete picture of the traffic levels. And sampling every hour would provide a complete picture in just a few weeks.

I'm not sure why odd-numbered frequencies are likely to ensure this. It seems to be based on an assumption that there are natural frequencies for program operations, and these are even.

相信这个概念对于我们做基于时间采样的性能分析,是十分有帮助的。

与其相忘于江湖,不如点击二维码关注Linuxer

Linux perf: 为什么采样频率设置为99Hz而不是100Hz?相关推荐

  1. 转:PHP网站在Linux服务器上安全设置方案

    PHP网站在Linux服务器上安全设置方案 本文总结了PHP网站在Linux服务器上一些安全设置(ps:还有一些设置给忘了),在<lnmp一键安装包>大多数参数已经包含,如果有什么更多的设 ...

  2. linux root密码激活,Linux - root初始密码设置

    Ubuntu刚安装后,不能在terminal中运行su命令,因为root没有默认密码,需要手动设定. 以安装ubuntu时输入的用户名登陆,该用户在admin组中,有权限给root设定密码. 给roo ...

  3. linux如何配置网络设置_如何在Linux中配置网络

    linux如何配置网络设置 将Linux计算机连接到网络非常简单,除非不是这样. 在本文中,我讨论了基于Red Hat的Linux发行版的主要网络配置文件,并介绍了两个网络启动服务:古老的网络启动和有 ...

  4. linux est 时间,Linux中的时区设置

    我通过将zoneinfo文件复制到/ etc / localtime,在我的Linux机器上将时区设置为GMT 6,但是date命令仍然将时间显示为UTCtime-6.任何人都可以向我解释这种行为吗? ...

  5. Linux命令提示行设置--SP1

    Linux命令提示行设置--SP1 2010/8/28 2:02:30 我的命令行提示符风格: PS1='[/[/033[01;32m/]/h:/[/033[01;34m/]/W/[/033[00m/ ...

  6. linux环境变量PS1设置完整版附带颜色

    linux环境变量PS1设置 ------------------------------------------------------------------------------------- ...

  7. 通过linux访问IPMI端口,Linux通过命令行设置IPMI的解决方法

    IPMI(智能平台管理接口)是一种开放标准的硬件管理接口规格,定义了嵌入式管理子系统进行通信的特定方法.使用低级硬件智能管理而不使用操作系统进行管理,具有两个主要优点: 首先,此配置允许进行带外服务器 ...

  8. linux创建交换分区设置_如何在Linux上创建交换文件

    linux创建交换分区设置 zentilia/Shutterstock.com zentilia / Shutterstock.com Add swap space to a Linux comput ...

  9. linux+dhcp+租约时间设置,Linux DHCP设置

    Linux DHCP服务端设置 首先要安装DHCP,如yum install dhcp 安装好了后所有的DHCP配置文件是放在/etc/dhcp/目录中,dhcpd.conf是主配置文件.刚装好DHC ...

最新文章

  1. 苹果8a1660是什么版本_iOS 13频繁“翻车”,果粉们面对苹果将情何以堪
  2. 背景建模与前景检测1(Background Generation And Foreground Detection)
  3. python入门-直方图
  4. 014 Android之Cydia与Xposed框架入门
  5. ajxs跨域 php_php设置header头允许ajax跨域请求
  6. java获取0点的时间戳_Java获取凌晨时间戳的方法分析
  7. Log4j2 升级到2.17.1踩过的坑
  8. 人脸检测三个算法比较
  9. 趣图:21 副 GIF 动图让你了解各种数学概念
  10. Together与Visual.Studio.NET的结合使用(一)
  11. 如何将卫星影像(高程)导出为西安80、北京54、国家2000坐标系
  12. tensorflow中model.compile()用法
  13. eval函数和repr函数
  14. android2.1操作系统,电脑安卓操作系统
  15. 建立数据思维的13个实用思维工具
  16. 新浪微博Android客户端开发之OAuth认证篇
  17. Linux查看全部进程的命令
  18. 【线性代数】7-2:线性变化的矩阵(The Matrix of a Linear Transformation)
  19. 检测手机号qq号是否开通微信的优势和好处
  20. 一种开环控制的两轮差速驱动小车的设计

热门文章

  1. 怎样用计算机打出歌,计算器怎么调成音乐键
  2. android数据库三个方法有哪些,如何将Android数据库操作通用化(二)
  3. Effective STL之算法
  4. 用这4步完成一个有理有据的LOGO 设计
  5. Android,IOS QQ在线客服代码
  6. MYSQL查询今天、昨天、7天前、30天、本月数据
  7. 基于CPLD的主板上电时序控制--状态机方式
  8. 【跨平台编程工具】XERO CODER 4.2.8.0 For x86 Cracked By PiaoYun/P.Y.G 优雅破解
  9. 宽带、专线等傻傻分不清楚——广域网协议
  10. 如何在eclipse中安装Jess