Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Dreaming of a Better Profiler

by Zaxo (Archbishop)
on May 25, 2004 at 21:33 UTC ( #356386=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://356386]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2021-10-21 23:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (85 votes). Check out past polls.

    Notices?