简体   繁体   English

“perf sched 记录”使用什么时间范围?

[英]What timeframe does the “perf sched record” use?

I've been trying to analyze the output of perf sched record but I don't understand with what frame of reference do I try to understand the "20624.983302 secs".我一直在尝试分析perf sched record的 output ,但我不明白我用什么参考框架来理解“20624.983302 secs”。 It isn't Unix time for sure, so what is it?现在肯定不是 Unix 时间,那是什么? How would I go about converting this into Unix time?我将如何将 go 转换为 Unix 时间?

*A0                               20624.983302 secs A0 => migration/0:12
*.                                20624.983311 secs .  => swapper:0
*B0                               20624.983318 secs B0 => IPC I/O Child:33924
*.                                20624.983355 secs 
*C0                               20624.983485 secs C0 => WRScene~lder#15:39974
*.                                20624.983581 secs 
*D0                               20624.983972 secs D0 => IPC I/O Parent:33780

These timestamps are captured using the kernel scheduler clock, which counts in nanoseconds since boot.这些时间戳是使用 kernel 调度程序时钟捕获的,该时钟自启动以来以纳秒计。 The exact details depend on the compile-time parameters chosen to build a particular Linux distribution and the target architecture.确切的细节取决于为构建特定 Linux 发行版和目标架构而选择的编译时参数。

In general, the timestamp of a sample is captured around the same time when it's recorded.通常,样本的时间戳在记录时大约在同一时间被捕获。 Timestamps on the same core are guaranteed to be monotonically increasing as long the core remains in an active state.只要内核保持在活动的 state 中,就保证同一内核上的时间戳单调递增。 The samples you've shown were all captured on the same core and the core remained active from the first sample to the last sample.您显示的样本都在同一个核心上捕获,并且核心从第一个样本到最后一个样本都保持活动状态。 So the timestamps are guaranteed to be monotonic in this case irrespective of the platform and distribution.因此,在这种情况下,无论平台和分布如何,都保证时间戳是单调的。 When profiling on multiple cores, there is no guarantee that the clocks on all cores are in sync.在多个内核上进行分析时,不能保证所有内核上的时钟都是同步的。

All perf tools use the same clock to capture timestamps, but they may differ in the way timestamps are printed and it may happen that two tools print timestamps from the same sample file differently.所有perf工具都使用相同的时钟来捕获时间戳,但它们的时间戳打印方式可能不同,并且两个工具可能会以不同的方式打印来自同一示例文件的时间戳。 This depends on the kernel version.这取决于 kernel 版本。

It's possible to specify a clock source when calling perf_event_open() by setting use_clockid to 1 and setting clockid to one of the clock sources defined in linux/time.h , such as CLOCK_MONOTONIC .在调用perf_event_open()时,可以通过将use_clockid设置为 1 并将clockid设置为linux/time.h中定义的时钟源之一来指定时钟源,例如CLOCK_MONOTONIC perf record provides the -k or --clockid option to specify the clock source for capturing timestamps. perf record提供-k--clockid选项来指定用于捕获时间戳的时钟源。

Modern distributions on x86 typically use TSC as the source for the scheduler clock (check /sys/devices/system/clocksource/clocksource0/current_clocksource ). x86 上的现代发行版通常使用 TSC 作为调度程序时钟的源(检查/sys/devices/system/clocksource/clocksource0/current_clocksource )。 So if you're on an x86 processor, most probably the TSC of the profiled core was used to capture the current value of TSC cycles, which internally gets converted into nanoseconds.因此,如果您使用的是 x86 处理器,则很可能已分析内核的 TSC 用于捕获 TSC 周期的当前值,该值在内部转换为纳秒。 When a timestamp is printed, it may get converted to a different unit.打印时间戳时,它可能会转换为不同的单位。 In this case, timestamps are printed in the format "seconds.microseconds".在这种情况下,时间戳以“seconds.microseconds”格式打印。 A summary of the behavior of TSC on Intel processors can be found at: Can constant non-invariant tsc change frequency across cpu states?英特尔处理器上 TSC 行为的摘要可在以下位置找到: Constant non-invariant tsc change frequency across cpu states? . .

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM