New Dynamic Instrumentation Profiling for .NET

Sagar Shetty

With the release of version 16.9 of Visual Studio, instrumentation profiling in Visual Studio just got better. Introducing our new dynamic instrumentation tool. This tool shows the exact number of times your functions are called and is faster than our previous static instrumentation tool. It also supports .NET Core instrumentation without needing PDBs.

Image 16 9 P3 dynamic instrumentaion

Try it yourself!

You can access the dynamic instrumentation tool by launching the Performance Profiler for a .NET Project in Visual Studio (Debug -> Performance Profiler or Alt-F2). Once you are on the summary page, select the Instrumentation checkbox.

When it comes to profiling there’s two mechanisms of collecting data. Collection via instrumentation or via sampling. With instrumentation, every function call in your application is annotated and instrumented so that when it gets invoked it’s added to the trace along with information about the caller. With sampling, the current call stack executing is polled from the CPU at an interval and then each frame is added to the trace.

The value of sampling is that it has less overheard and is thus more likely to be statistically representative of the application running in production. The value of instrumentation profiling is that you can get exact call counts on how many times your functions were called. This gives you much more detailed information than normal sampling profiling cost of distorting the time taken in some scenarios. For example functions that don’t do much, but are called frequently will show up more than they would in the real world.

Image instrumentation call counts

With the new dynamic instrumentation scenario there are a few more benefits. First you should see performance improvements in how quickly the tool is able to run. This is because we no longer need to use VSInstr to use instrumentation in this scenario.

Second, our dynamic instrumentation supports .NET Core projects without PDBs. Before you had to modify your build to produce full PDBs in order to use instrumentation. Ultimately, this means you can run your projects as is without needing to do any extra work to instrument your managed code.

Finally, we have architected this instrumentation tool to not require modifying your assembly files. This means that we won’t accidentally break any signing you may have and be able to instrument all your managed code.

Come talk with us!

If you want to speak with our engineering team on how we can improve this tool, please fill out the survey below. We will be reaching out to customers soon.

Happy profiling!