On 05.01.2010, at 18:34, Tim Bunce wrote:

> The is_pmc logic was added for Larry Wall so he could profile his
> STD.pm Perl6 compiler.  I've forgotten the details now, except that the
> way it currently works suited his needs at the time.
> 
> If you give me detailed instructions to reproduce the problem you're
> seeing I'll ponder what changes I might make.


Hello Tim

I'll look into creating a reduced test case soon.


>> 2) Hi-Resolution Clocks on Mac OS X
>> 
>> It's possible to at least simulate clock_gettime on Mac OS X by using
>> the Mach time functions. A code example for that is e.g. here:
>> http://le-depotoir.googlecode.com/svn/trunk/misc/clock_gettime_stub.c
> 
> Thanks. Based on http://developer.apple.com/mac/library/qa/qa2004/qa1398.html
> it seems.
> 
>> Maybe something similar could be integrated into NYTProf to increase
>> the accuracy of its reports on Mac OS X.
> 
> That would be great! Could you produce a patch for that?
> 
> Pretty simple. Something along the lines of... adding the file and
> $mm_opts{DEFINE} .= '-DHAS_CLOCK_GETTIME -DCLOCK_GETTIME_OSX_EMU';
> into Makefile.PL at an appropriate spot, and something like
>    #ifdef CLOCK_GETTIME_OSX_EMU
>    #include "clock_gettime_stub.c"
>    #endif
> in NYTProf.xs.

I've looked at the example code again a bit closer and then went with my own 
mach_absolute_time based implementation which is simply based on different 
macros and included it as default replacement for gettimeofday on Mac OS X. The 
clock_gettime_stub.c was unfortunately unusable: Mach's clock_get_time is 
painfully slow (time of profiling increased by a factor of 4, even after I 
optimized the code to not constantly re-acquire the clock port) and the 
PROCESS_CPUTIME_ID/THREAD_CPUTIME_ID branch of the code was completely flawed 
(it seems the author misunderstood the tech note and did not realize, that he's 
actually measuring the performance of the getpid()/sched_yield() calls instead 
of returning the proper time).

Please see the attached patch - I hope everything's ok with it. I've set the 
resolution of the mach clock to 100ns similar to the clock_gettime variant - 
the macros actually calculate it in 1ns resolution. I've got no clue what the 
real resolution of mach_absolute_time is (it pretends it's 1ns but well...), 
but so far my tests indicated that the resolution is at least a lot higher than 
with gettimeofday.



-- 
Markus Peter - [email protected] - http://www.spin-ag.de/ - http://www.spin.de/
SPiN AG, Bischof-von-Henle-Str. 2b, 93051 Regensburg, HRB 6295 Regensburg
Aufsichtsratsvors.: Dr. Christian Kirnberger, Vorstände: F. Rott, P. Schmid

Attachment: machtime.patch
Description: Binary data

-- 
You've received this message because you are subscribed to
the Devel::NYTProf Development User group.

Group hosted at:  http://groups.google.com/group/develnytprof-dev
Project hosted at:  http://perl-devel-nytprof.googlecode.com
CPAN distribution:  http://search.cpan.org/dist/Devel-NYTProf

To post, email:  [email protected]
To unsubscribe, email:  [email protected]

Reply via email to