Profiling FAQ #6: Why does the profiler say Foo calls Bar, when I know it doesn’t!

Here's another fun one from the internal support alias.

When you profile with the VS Profiler, you are profiling the Release version of your code (I hope!). As you know from having debugged Release code in the past, sometimes things get a little funky. Well, a good rule of thumb is that anything that is funky in the debugger, is also a little funky in the profiler. After all, we share the same symbol information (i.e., the stuff in the PDBs for native code and the managed metadata in the EXEs and PDBs for managed code.)

One optimization that is particularly tough for the profiler is called COMDAT folding. There's a good explanation of this from a debugger standpoint here:

The basic concept is that at link time, all identical functions at code generation time are folded in to a single copy of that function. This is particularly useful for limiting the code bloat in template code. You will see COMDAT in action with things like default destructors and simple methods like field accessors. Since there is only one copy of that function in the binary with several source level functions associated with it, if we take a sample in it, there is no way for us to know which is the correct function. So we just pick the first one in the list, just like the debugger.

Hope that helps!

Comments (2)
  1. Cleaning-out my “To Blog” file again…


    Handling data in service oriented systemsEdward…

  2. The profiler team has been crazy busy with getting Visual Studio Team System shipped and out the door,…

Comments are closed.

Skip to main content