Why there is a fairly large variance in retired instructions between subsequent runs of 'perf stat'?
Issue
- Why there is a fairly large variance in retired instructions between subsequent runs of
perf stat –e instructions <my-executable>. Disabling Address Space Layout Randomization withsetarch $(uname –m) –LRdoes not seem to make any difference.
For example :
# cat testcase.c
#include <stdio.h>
int main(int argc, char* argv[])
{
int i;
for (i = 0; i < 100000000; ++i);
return 0;
}
- If above program is run 5 times via
setarch $(uname -m) -RL perf stat -e instructions ./testcase, it shows significantly different results:
# for i in {1..5}; do setarch $(uname -m) perf stat -e instructions ./testcase; done |& grep instructions
300,930,235 instructions # 0.00 insns per cycle
300,939,461 instructions # 0.00 insns per cycle
300,925,166 instructions # 0.00 insns per cycle
300,935,742 instructions # 0.00 insns per cycle
300,930,628 instructions # 0.00 insns per cycle
- Why there is such variance and if there is something we can do to reduce it?
Environment
- Red Hat Enterprise Linux
- perf
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.