runtime

Performance Requirements

The .NET runtime supports a wide variety of high performance applications. As such, performance is a key design element for every change. This guidance is designed to share how we collect data and analyze the performance of the runtime.

You may also want to read about performance coding guidelines.

Design Phase

Make sure to address performance during the design phase of any change. It is much easier to tweak a design to fit performance goals and requirements before implementation has started.

Here are some guidelines about how to think about performance during design:

Cache Considerations

A few guidelines to consider if you’re planning to add a cache. In addition to their upsides, they also come with downsides:

Prototyping

If you need to convince yourself that the performance characteristics of a design are acceptable, consider writing a prototype. The prototype should be just enough to be able to run a scenario that meets the scale requirements. You can then capture a performance trace and analyze the results.

Creating a Microbenchmark

A microbenchmark is an application that executes a specific codepath multiple times with the intention of monitoring that codepath’s performance. The application usually runs many iterations of the code in question using a fine granularity timer, and then divides the total execution time by the number of iterations to determine the average execution time. You may find times where you’d like to understand the performance of a small piece of code, and in some cases a microbenchmark is the right way to do this.

The microbenchmarks used to test the performance of all .NET Runtimes live in dotnet/performance repository. The benchmarking workflow is described here.

Profiling and Performance Tracing

Measuring performance is an important part of ensuring that changes do not regress the performance of a feature or scenario.

Using a profiler allows you to run an existing workload without adding tracing statements or otherwise modifying it, and at the same time, get rich information on how the workload performs.

The profiling workflow is described here.

Additional Help

If you have questions, run into any issues, or would like help with any performance related topics, please feel free to post a question. Someone from the .NET performance team will be happy to help.