Having difficulty profiling threads

Code profiling for .NET Developers

Moderators: Luke Jefferson, StephenC, Alex.Davies, AndrewH, melvyn.harbour, Laura Morley

Having difficulty profiling threads

Postby talbot » Tue Jul 13, 2010 4:47 am

We are trying to profile a multi-threaded .NET application that has dependencies on unmanaged code, Microsoft.XNA, etc.

We have created a managed project that generates a dll. We are able to see some of our methods getting profiled - but not the ones of interest. Specifically, the ones responsible for scene rendering.

We're not certain what is stopping RedGate ANTs profiler from being able to profile certain methods - but at the top of the call-stack (for one of the methods in question) is:

Then lower in the call-stack is a call to native code and subsequently back to managed code - i.e. this is in the call-stack:
[Native to Managed Transition]
[Managed to Native Transition]

Immediately above the managed to native transition (in the call-stack) is this call:
WindowsBase.dll!System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame frame = {System.Windows.Threading.DispatcherFrame})

In general - what would preven redgate ANT's performance profiler from being able to profile managed code? Is there a work-around we could use to be able to profile managed code that just happens to be invoked by unmanaged code? For example, in Visual Studio, you can just click the check-box "enable unmanaged code debugging". Although we don't want to debug/profile unmanaged code - I'm wondering if that concept is prohibiting us from profiling the managed code (that just so happens to be invoked by unmanaged code).

Posts: 1
Joined: Tue Jul 13, 2010 4:36 am

Postby AndrewH » Tue Jul 13, 2010 10:34 am


ANTS shouldn't miss any methods when using any of the 'all methods' profiling modes. However, there are a few options that can change how this is presented to you:

If 'Enable Inlining' is on (it is by default), then .NET may inline certain methods, which the profiler will report as taking no time as a result. These will only show up in the results (in orange) if you have 'hide insignificant methods' turned off.

'Simplify complex stack traces' can sometimes results in method disappearing. Turning this option off might result in the profiler using up too much memory and crashing the target application.

If 'avoid profiling extremely trivial functions' is on, then the profiler will save disk space and memory by ignoring methods with an infinitesimal effect on the result (this generally means property accessors that are only called once).

If you're using sampling mode, be aware that the profiler won't be able to see function calls that take place in an interval less than the sampling period - generally anything that takes less than about 2ms to complete; about 99% of .NET function calls actually fall into this category.

It might also be the display options: to see everything make sure that you've selected an 'any methods' display mode and turned 'hide insignificant methods' off.
Andrew Hunter
Software Developer
Red Gate Software Ltd.
Posts: 134
Joined: Thu Aug 17, 2006 3:44 pm

Return to ANTS Performance Profiler 6

Who is online

Users browsing this forum: No registered users and 0 guests