Please enable Javascript to view the contents

 ·  ☕ 2 分钟

reference cycle

https://easyperf.net/blog/2018/09/04/Performance-Analysis-Vocabulary

Majority of modern CPUs including Intel’s and AMD’s ones don’t have fixed frequency on which they operate. Instead, they have dynamic frequency scaling. In Intel’s CPUs this technology is called Turbo Boost, in AMD’s processors it’s called Turbo Core. There is nice explanation of the term “reference cycles” on this stackoverflow thread:

Having a snippet A to run in 100 core clocks and a snippet B in 200 core clocks means that B is slower in general (it takes double the work), but not necessarily that B took more time than A since the units are different. That’s where the reference clock comes into play - it is uniform. If snippet A runs in 100 ref clocks and snippet B runs in 200 ref clocks then B really took more time than A.

$ perf stat -e cycles,ref-cycles ./a.out
 Performance counter stats for './a.out':
       43340884632      cycles		# 3.97 GHz
       37028245322      ref-cycles	# 3.39 GHz
      10,899462364 seconds time elapsed

I did this experiment on Skylake i7-6000 process, which base frequency is 3.4 GHz. So, ref-cycles event counts cycles as if there were no frequency scaling. This also matches with clock multiplier for that processor, which can find in the specs (it’s equal to 34). Usually system clock has frequency of 100 MHz, and if we multiply it by clock multiplier we will receive the base frequency of the processor.

分享

Mark Zhu
作者
Mark Zhu
An old developer