|Just another Perl shrine|
Re: nytprof warningby Old_Gray_Bear (Bishop)
|on Jun 03, 2011 at 23:40 UTC||Need Help??|
I seem to remember reading somewhere (probably the NYTP POD) that negative times could come about on multi-core/multi-cpu SMP (Symetric Multi-Processor) machines where the code being profiled got started on one CP, took and interupt, and was re-dispatched on another CP. Since almost all modern hardware is some form SMP architecture, this probably applies to your problem. Let me go digging ...
Found it -- it's in the POD under CAVEATS -- basically each processor maintains its own personal Time Register that is synchronized with the master time-source at regular intervals. Between synch-points the Time Register may drift. There is circuitry that attempts to limit the excursion off of the synch-point, and the synch-points occur frequently enough to limit the drift, as well.
From the Fine manual:
The Processors in an SMP system do not start all at exactly the same time, therefore the timer registers are typically running at an offset. ...
I've seen negative durations in the current profiling project, but they have been associated with routines that I expect to be interrupt-able (mostly socket-based I/O). And, the number of times the routine gets called doesn't make it a candidate for serious work -- when you have one routine that gets called 10K times at 200 milliseconds a pop, and your I/O routine gets called twice with an exclusive-time of -0.0001, who you going to concentrate on?