dotTrace 2021.1 Help

Configure Profiling Session

To configure a profiling session, you should:

  1. Specify how dotTrace should run the application you wish to profile. You can do this with the help of run configurations. If you want to profile an already running application, this step is not required.

  2. Specify how dotTrace should profile the application: select a profiling type and (optionally) configure other profiling options, like, time measurement type, process filters, and so on.

1. Creating a run configuration

A run configuration is the way to tell dotTrace how it should run the profiled application. For example, a run configuration of a standalone .NET application will include a path to the application executable, command-line arguments, and a path to the application working directory.

If you already have a run configuration for the profiled application, select this run configuration from the New Process Run under Choose what you want to profile. Otherwise, create the run configuration by following the instruction below.

To create a run configuration

  1. Under Choose what you want to profile, New Process Run, click Add run configuration Add run configuration.

  2. In the New Run Configuration wizard, choose the application type and provide application options:

  3. Click Save. This will create and save the run configuration. Next time when you need to profile this application, select the created configuration from the New Process Run list.

2. Choosing profiling type

Choose a profiling type in Profiling Type under Choose how you want to profile it.

The profiling type defines the way of how dotTrace collects profiling data and as a result – the amount and the type of the collected data. The following table will help you choose the best suitable profiling type. For more details, refer to Basic Concepts.

Description Use Case
SamplingAccurate time measurement, number of calls is not measured.

Recommended for most cases. Ideal when you look for performance issues in your app for the first time.

TracingAccurate calls count measurement, time measurement may be inaccurate due to profiling overhead.When sampling data is not enough. For example, for analyzing algorithm complexity (when info about number of calls is more valuable than call time values).
Line-by-lineEach line of code is measured, call time values are inaccurate due to huge profiler overhead.
To lower the overhead, you can profile only particular methods using filters.
For advanced use cases only. For example, when you already know what function causes issues and want to analyze each line of it.
TimelineCollects temporal data about thread states, application events, and other multi-threading data. Based on Event Tracing for Windows (ETW).

Recommended for most cases. Especially, for analyzing multithreaded apps. Use it, for example, to determine the cause of UI freezes, excessive garbage collections, uneven workload distribution, insufficient I/O, and so on.

3. Configuring other profiling options

  • Time measurement
    This option defines how dotTrace must calculate calls time. Typically, this is a choice between whether dotTrace should calculate time when a thread is not working or should not. For more details, refer to Time Measurement Methods.

    Real time (performance counter)Recommended. dotTrace calculates the overall real time passed between method entry and exit. This time does not depend on app threads states. Time is calculated using system performance counter.
    Real time (CPU instruction)dotTrace calculates the overall real time passed between method entry and exit. This time does not depend on app threads states. Time is calculated using the CPU register.
    Thread timedotTrace calculates only the time when a certain thread is running. The time when the thread is waiting or sleeping is not included in calculation.
    Thread cycle timedotTrace calculates only the time when a certain thread is running. The time when the thread is waiting or sleeping is not included in calculation. Time is calculated using the CPU register.

    The table next in this section will help you to choose a time measurement method better suitable for your case.

  • Enable inlining

    (Tracing, Line-by-line) Clear this option if you want dotTrace to turn off JIT-inlining and get call stacks that closely resemble the structure of application's source code.

  • High accuracy

    (Tracing, Line-by-line) If selected, dotTrace will take into account time spent in profiler itself by taking more time samples.

  • Enable native profiling

    (Timeline, Unity/Mono on Windows) If selected, dotTrace will collect native call stack data. The resulting snapshot will contain both managed and native call stacks. This profiling option may be helpful for finding performance issues in Unity games.

  • Collect native allocations

    (Timeline) If selected, dotTrace will collect information about all memory allocations the profiled application does in the native (unmanaged) heap. To be able to select this option, you must have Windows Performance Toolkit installed on your computer.

  • Collect debug output

    (Timeline) If selected, dotTrace will collect information about all messages the profiled application sends to the debug output.

  • Collect TPL events

    (Timeline) If selected, profiling performance may be affected but dotTrace will collect Task Parallel Library (TPL) data. If cleared, there will be no Task nodes in Call Tree and async call nodes will lack their await and continuations parts. Learn more about how dotTrace works with asynchronous code in Analyzing Async Calls.

    Clear this option in case your application does not use multitasking or you do not need this info.

  • How to control profiling

    Manually (default): you control the profiling session using the buttons of the profiling controller window. For example, to take a snapshot, you click Get Snapshot and Wait.

    Using API: you control profiling directly from the code of the profiled application. For example, to take a snapshot in the exact point of your code, you call the MeasureProfiler.SaveData() function. Learn more about using the API in Controlling Profiling Process Through API.

  • Collect profiling data from start

    If selected, dotTrace will start recording profiling data right after the launch. Otherwise, dotTrace will start collecting these data only after you click Start in the profiling controller window.

4. (Optional) Configuring process filters

If the profiled application creates a number of processes, use the Process filters setting to specify what processes you want to profile. You can either select a predefined filter or create a new one.

Note that process filters work differently depending on the application type specified in the selected run configuration.

App typeDescription

Standalone

.NET Core Application

Mono Application

Unity Application

dotTrace will profile only processes that match the specified filter. The filter is applied to the entire process tree of the profiled process (including child processes).

For example, you have a managed process that creates a number of child processes. You want to profile not only the main process but also child processes with service in their name. To do this, add the *service* include filter.

.NET Process

In this mode, starting the profiling session does not start the profiled process. Instead, dotTrace waits for and attaches to the first managed process started in the operating system. When certain Process filters are selected, dotTrace will attach to the first process that matches the filter.

For example, you created the include filter: *service*. dotTrace will attach to the first process in the system with service in its name.

IIS

IIS Express

Windows Service

WCF Service

WinRT Application

Process filters are not applied.

To select a process filter

  1. Under Choose how you want to profile it, Advanced Options, open the Process filters list.

  2. Select the required filter.

    dotTrace provides two predefined filters:

    • Default: process filter is not applied.

    • Entire process tree: dotTrace will profile the entire process tree including child processes. In case a .NET Process run configuration is selected, dotTrace will attach to and profile the first managed process started in the system including all its child processes.

    Select a predefined filter

To create a process filter

  1. Under Choose how you want to profile it, Advanced Options, open the Process filters list.

  2. Choose Add Filter.

  3. Specify filter settings:

    • Name: filter name.

    • Profile entire process tree: if selected, dotTrace will profile the entire process tree including child processes. Disabling this option makes sense only if you create a filter for the .NET Process run configuration. In this case, dotTrace will wait for and attach to the first process in the system that matches the filter but it will not profile child processes of this process.

    • Include filter masks, Exclude filter masks: include and exclude filter masks correspondingly. The masks are applied according to the following rules:

      • The default policy is 'profile all'.

      • Include masks are applied first. Exclude masks are applied to the processes filtered by the include masks.

      • You can use asterisk * wildcards.

      For example, to profile all child processes with Service in their name excluding MyService, add the *Service* include mask and the MyService exclude mask.

  4. Click Save.

5. (Optional) Configuring filters for the line-by-line profiling

Line-by-line profiling may be effective in particular cases but it is always time-consuming. To somehow minimize the profiling overhead, you can define some rules. According to them, not all functions are profiled line by line but only those that are really interesting for further investigation.

So you can create and set a filter or filters that match only the functions/classes/assemblies you need.

To create a filter for the line-by-line profiling

  1. Under Choose how you want to profile it, select the Line-by-Line profiling type.

  2. Click Edit Filters.

  3. Click Add filter Add filter in the Edit Filter dialog.

  4. Choose a filter type:

    • Profile code in: include the specified code item into profiling and exclude all other code items.

    • Do not profile code in: exclude the specified code item from profiling.

    • Do not profile code marked with attribute: exclude code items with the specified attribute from profiling.

  5. If you have chosen one of the first two options, specify an assembly, a class, and/or a method to be included or excluded from profiling. Code items are filtered independently on one another. For example, if you specify a method and leave asterisks * for assembly and class to exclude methods with the specified name from all assemblies and all classes.

  6. If you have chosen the last option, specify the name of the attribute that will be used to exclude symbols from profiling. Optionally, specify the assembly name where this attribute is declared.

    You can use asterisk wildcards when specifying code item names in a filter: * (asterisk) represents zero or more characters. For example, the *.Tests wildcard will exclude all test projects from code analysis.

  7. Click OK.

Last modified: 08 March 2021