2

I want to measure how my Pintool worsens the execution time of an executable in the case where it simply does "empty instrumentation".

Basicly in my Pintool I got a callback which is called every time an Image is loaded which, in turn, inserts analysis functions for specific routines.

So I was thinking of measuring the "empty instrumentation" overhead using two modes of operation:

  1. Having an empty Image callback function, to be called when each image is loaded, instead of the ordinary one
  2. Having empty routine analysis functions to be called instead of the ordinary ones

Is this approach viable? Are there better solutions I am unaware of?

Hadi Brais
  • 22,259
  • 3
  • 54
  • 95
Simus
  • 319
  • 2
  • 18

1 Answers1

1

Pin performs a number of optimizations to generate very efficient instrumented code. In particular, empty analysis routines will definitely get inlined into the application routines. Empty functions in C/C++ will most likely get compiled to a single instruction (on x86, it's some form of ret). Pin may be able to recognize that and completely remove that instruction, leaving you with zero instrumentation. You can determine whether Pin removes ret by comparing the performance without any instrumentation and that of with empty analysis routines. If the difference is zero, there is a good chance that Pin eliminated the instruction. Although this is not documented as far as I know.

Hadi Brais
  • 22,259
  • 3
  • 54
  • 95
  • Would there still be zero instrumentation if, instead of empty callbacks, I used callbacks which do very simple operations with negligible overhead, e.g. incrementing a counter? – Simus May 31 '18 at 08:19
  • @Simus Callbacks don't get inlined, only analysis routines. if you increment a global counter or a thread-local counter in an analysis routine, then there will be some instrumentation. – Hadi Brais May 31 '18 at 14:41