salva has asked for the wisdom of the Perl Monks concerning the following question:

Hi

I am trying to profile an XS module on a Linux box.

I have recompiled perl 5.8.8 adding -pg to optimize, ldflags and lddlflags on config.sh and also recompiled my module with this new perl.

Now when I run a test script the gmon.out file is generated, but it only contains information about the perl internals, nothing about the functions on the dynamically loaded XS modules.

Do I need to do anything else?

Replies are listed 'Best First'.
Re: profiling an XS module
by rg0now (Chaplain) on May 31, 2007 at 11:52 UTC
    Well, if I were you, I would stop thinking in the good old GNU gprof-style profiling model, and I would start to look into modern and less tedious profiling frameworks. Unfortunately, with gprof you do not have really good chances of getting anything useful on a modern CPU unless you run your code for minutes, because it samples your code only every 10 millisconds or so, which is a bit too rare nowadays.

    In particular, I am thinking about you could try Valgrind or OProfile (if you are lucky enough to be using Linux). Both allow you to profile code without specially compiling it for profiling, and they also provide much better granularity than gprof. With the latter I don't have too much experience, but with the former (and, especially, callgrind) I have already had the chance to make myself acquainted to my greatest programming and profiling pleasure.

      Today, I have been able to try Valgrind profiler, callgrind, and it is amazing, specially when combined with KCacheGrind.

      Thank you for the pointer!