- System requirements
- Profiler architecture
- Profiler installation
- Uninstall profiler
- Running the profiler
- Profiler activation
- Welcome screen
- Start profiling
- Profiling overhead
- Snapshots
- Solving performance problems
- CPU profiling
- Thread profiling
- Object allocation profiling
- Memory profiling
- Exception profiling
- Telemetry
- Probes: monitor higher level events
- Inspections: automatic recognition of typical problems
- Automatically trigger actions on event
- Automatic deobfuscation
- Summary, automatic deobfuscation
- Filters
- Profiler command line
- Command line tool to control profiling
- Export of profiling results to external formats
- Profiler .NET API
- Profiler HTTP API
- Settings
- Troubleshooting
Profiling overhead
- The nature of overhead
- Key strategies for reducing profiler overhead
- CPU profiling
- Thread profiling
- Memory profiling
- Exception profiling
- Telemetry
- Probes
The nature of overhead
When profiling a .NET application, the profiler agent collects data about the running program. This involves calling operating system methods, invoking .NET runtime APIs, and instrumenting bytecode (inserting special support code into function bodies). Naturally, data collection consumes resources (memory and CPU) and adds overhead, leading to slower application performance.
The extent of the slowdown depends on the profiling mode: the more data collected and the costlier the data acquisition, the greater the slowdown. For instance, CPU tracing requires measuring the time at the entry and exit of each method to calculate the time spent inside the method and count how many times the method was called. Despite efforts to optimize the profiler agent, overhead is inevitable.
To manage this, YourKit .NET Profiler is designed to give developers complete control over the amount of collected data, allowing them to adjust the profiler's overhead. By disabling the collection of unnecessary data, you can effectively reduce the overhead to zero. This approach ensures that you can maintain application performance while still gaining valuable insights from profiling.
Key strategies for reducing profiler overhead
- On-demand profiling: Enable profiling only when needed, rather than running it continuously throughout the application's lifecycle.
- Adjust data granularity: Choose a lower level of detail for data collection.
- Limit data retention: Configure the profiler to discard older or less relevant data, keeping memory usage in check.
CPU profiling
- Turn CPU profiling off, if you are not profiling the CPU.
- Use sampling instead of tracing if method invocation counts are not required.
-
If method invocation counts are unnecessary,
utilize the
disable_tracing
option to completely disable bytecode instruction for tracing.
Thread profiling
- Turn thread profiling off if you are not analyzing thread interactions and do not need to estimate CPU usage over time intervals.
- Collect only thread states instead of states and stacks if the CPU estimation feature is not required.
-
Avoid specifying a long
telemetry_limit
; in most cases, the default 1-hour limit suffices.
Memory profiling
- Turn off object allocation profiling if you are not analyzing the creation of temporary objects.
- Opt for the Count allocated objects mode if you do not require exact stack traces of where the objects were created, but only need the number of created instances.
-
If object allocation profiling is not needed,
use the
disable_alloc
option to completely disable bytecode instruction for allocation profiling.
Exception profiling
- Turn off exceptions profiling if you are not analyzing exception throwing.
-
Use the option
exceptions=disable
to completely avoid the overhead of exception profiling.
Telemetry
- Do not collect telemetry if it is not needed.
-
Avoid setting a fast telemetry sampling rate with the option
telemetry_period
. The default 1-second rate suffices in most cases. -
Avoid specifying a long
telemetry_limit
; in most cases, the default 1-hour limit suffices.
Probes
- Turn off or disable the probes you are not interested in collecting.
-
Avoid using large values for
probe_table_length_limit
. -
Use the option
probe_disable=*
to disable all probes and completely avoid the overhead of probe collection.