Again, I am using Mac OS X 10.6.3.


First, I am curious, how is DTrace getting the function name information for a 
release build when all of it's symbols have been stripped from it and there is 
not dSym file either in the application package or adjacent to it? For example, 
I create the default Cocoa Application, and wrote:

- (void) myRandomMethod
{
        int x;
                
        for ( x = 0; x < 9000000; x++ )
        {
        }
}

- (void) applicationDidFinishLaunching:(NSNotification *)aNotification 
{
        [self myRandomMethod];
}


sudo dtrace -l -n 'pid1221:MyApp::entry' produced the following results for the 
release build:

   ID   PROVIDER            MODULE                          FUNCTION NAME
26601    pid1221             MyApp                             start entry
26602    pid1221             MyApp                              main entry
26603    pid1221             MyApp -[MyAppAppDelegate myRandomMethod] entry
26604    pid1221             MyApp        -[MyAppAppDelegate window] entry
26605    pid1221             MyApp    -[MyAppAppDelegate setWindow:] entry
26606    pid1221             MyApp -[MyAppAppDelegate 
applicationDidFinishLaunching:] entry
26607    pid1221             MyApp                      stub helpers entry


Now, there is a dSym file for this application, but for DTrace to find it, it 
would have needed to search the drive for it's location...

---
---
---

I am looking into the performance hit of doing probe enabled checks.

To test this, I created the default Cocoa application and then wrote:

- (unsigned long) myMethod:(unsigned long)inX
{
        return inX + 1;
}

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification 
{
        if ( DTRACETEST_TEST_START_ENABLED() )
                DTRACETEST_TEST_START();
                
        unsigned long x;
        unsigned long y = 0;
        
        for ( x = 0; x < 1000000000; x++ )
        {
                y = [self myMethod:x];

                if ( DTRACETEST_TEST_MINE_ENABLED() )
                {
                        DTRACETEST_TEST_MINE();
                }
                
        }
        
        if ( DTRACETEST_TEST_END_ENABLED() )
                DTRACETEST_TEST_END();
        
        printf( "%lu", y );
        
        // Insert code here to initialize your application 
}

In the Debug build,

If I remove DTRACETEST_TEST_MINE_ENABLED block, the time between the start and 
end probes is ~8.8 seconds.
Adding DTRACETEST_TEST_MINE_ENABLED back in, but keeping the probe disabled 
(i.e. DTRACETEST_TEST_MINE_ENABLED returns false), took ~8.9 seconds.

In the Release build,

If I remove DTRACETEST_TEST_MINE_ENABLED block, the time between the start and 
end probes is ~5.7 seconds.
Adding DTRACETEST_TEST_MINE_ENABLED back in, but keeping the probe disabled, 
took ~6.4 seconds.

The overhead has increased significantly in the release build.

This doesn't seem like it is as close to zero cost as I initially thought it 
should be, leading me to think that i may not be measuring what I think I am 
measuring. 

Based on these results, it would seem that one would want to keep probes out of 
the tightest loops in an application.

But, considering how pervasive such things are even in Mac OS X, my conclusion 
does not seem to be correct.



Thank you.



_______________________________________________
dtrace-discuss mailing list
dtrace-discuss@opensolaris.org

Reply via email to