Is there a real instruction counter on modern x86 CPUs?
Posted: Thu Feb 06, 2020 5:57 pm
After some headbanging and a bit of late googling i discovered that on modern x86 CPUs the RDTSC instruction does not return actual instruction count, and is instead normalized to some system frequency.
This means that as the CPU clock gets changed by nice things like turbo boost, the counter keeps ticking at the same rate.
It no longer measures how many instructions a CPU performed between two invocations, but is now just a clock.
And a clock is not useful when you try to benchmark a bit of code on an x86 tablet that can vary between 1.1GHz and 2.4GHz with no way of nailing it down.
So the question is, is there some new instruction, MSR, or something that holds an actual instruction count?
This means that as the CPU clock gets changed by nice things like turbo boost, the counter keeps ticking at the same rate.
It no longer measures how many instructions a CPU performed between two invocations, but is now just a clock.
And a clock is not useful when you try to benchmark a bit of code on an x86 tablet that can vary between 1.1GHz and 2.4GHz with no way of nailing it down.
So the question is, is there some new instruction, MSR, or something that holds an actual instruction count?