Why there is a fairly large variance in retired instructions between subsequent runs of 'perf stat'?

Solution Verified - Updated -

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 with setarch $(uname –m) –LR does 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 of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.