in reply to Dreaming of a Better Profiler

An actual interrupt handler on Linux would indeed take a kernel module. Probably any other Unix, as well. There aren't that many unused interrupts around on x86, either.

How about something like this?

  1. fork a child which issues kill USR1, $parent now and then.
  2. In the parent define a $SIG{USR1} handler which increments a global hash of counts of curcop.

That is not perfect. Generally speaking, neither is the interrupt sampler you describe. With safe signals, the opcode following a long-running instruction like gethostbyname will be way oversampled. In either case sampling gets you running time statistics, but you give up coverage data.

My own notion of a neat profiler for perl would make use of the performance counter registers of modern processors. I've worked on that some. Maybe I should resurrect that project.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re: Re: Dreaming of a Better Profiler
by samtregar (Abbot) on May 25, 2004 at 21:38 UTC
    How about something like this?

    That's a reasonable idea, and it might just work. It might also have too much overhead to run fast enough to get a good sampling rate. At the very least it could be a good way to get the curcop-logging and subroutine-name resolution code working without tackling the interupt handler.

    My own notion of a neat profiler for perl would make use of the performance counter registers of modern processors. I've worked on that some. Maybe I should resurrect that project.

    That sounds very interesting. Can you suggest any reading material on the subject?

    Thanks,
    -sam

      The Intel processor manuals are probably the best reference for the low-level stuff. They are available online in pdf format.

      Perfctr is a Linux kernel patch and user library which permits users to access the performance counters on a per-process basis. One drawback to that approach is that is very platform specific. It would be difficult to write a perl module distribution of acceptable generality.

      After Compline,
      Zaxo