dotTrace 2023.3 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. Create 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. Choose 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 information, refer to Basics. Profiling Types.

Description

Use Case

Timeline

Collects temporal data about thread states, application events, and other multi-threading data. Based on Event Tracing for Windows (ETW). Supports native profiling.

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.

Sampling

Accurate 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.

Tracing

Accurate 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-line

Windows only.

Each 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.

3. Configure other profiling options

Sampling rate

(Timeline on Windows)

dotTrace takes stack trace data from Windows kernel. By default, the kernel provides 1000 sample events per second. You can increase the sampling rate up to 8000 samples/sec. This makes sense, for example, in game development, when you want to profile fast-executing native code. The higher the sampling rate, the more accurate the results are, but the larger the snapshot is.

Control profiling

Manually (default)

Control the profiling session using the buttons in the profiling controller window. For example, to take a snapshot, you click Get Snapshot and Wait.

Using API

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.

Not available for the Timeline profiling type for standalone applications on Linux and macOS.

Time measurement

(Sampling, Tracing on Windows, Line-by-line)

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 information, refer to Basics. Time Measurement.

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 time

dotTrace 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 time

dotTrace 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.

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 on Windows)

If selected, dotTrace will collect information about all memory allocations the profiled application does in the native (unmanaged) heap.

  • Sample allocations every ... KB defines the size of the allocated memory that will trigger a memory allocation sample. The default value is 100 KB. This means that a sample is triggered once the size of allocated memory exceeds 100 KB in total. For example, a native thread allocates five 50 KB memory blocks during profiling. In such a case, dotTrace will detect only two allocations of 100 KB.

    The smaller the size, the more accurate the results are and the larger the snapshot is. Use this option to find the optimal balance between the data accuracy and snapshot size.

  • If Collect only unreleased allocations is selected, dotTrace will save into the snapshot only data about those allocations that were still in the unmanaged heap on the moment of taking the snapshot.

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 be shown without their await and continuations parts.

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

Collect debug output

(Timeline on Windows)

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

Download symbol files

(Timeline on Windows)

PDB files (or symbol files) let you see native functions in the call tree. This is relevant for native applications and managed applications that call native code. If you select Download symbol files, dotTrace will try downloading PDB files from remote servers right after you get a snapshot. Note that this may take a significant amount of time depending on file size.

By default, dotTrace looks for PDB files in the locations specified in the _NT_SYMBOL_PATH environment variable. Alternatively, you can specify custom local or remote locations using Edit Symbol File Locations.

If Download in background is enabled, dotTrace starts downloading symbol files while the profiling session is running. This may help to reduce the time of taking a snapshot.

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) Configure 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 type

Description

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) Configure 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: 16 January 2024