- 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 and FAQ
Exception profiling
Goals of exception profiling
YourKit .NET Profiler records thrown exceptions and their stack traces. Use this data to find performance bottlenecks and unexpected error paths.
Throwing exceptions is expensive
Throwing exceptions can be expensive, especially when it happens frequently. When an exception is thrown, the .NET runtime performs exception dispatch. This can include:
- Capturing or updating the exception stack trace.
- Searching the current method and its callers for a matching exception handler and evaluating exception filters.
-
Unwinding the stack and executing applicable
finallyand fault blocks. - Transferring control to the selected handler.
This work makes throwing an exception much slower than following the normal control flow. The cost can increase with stack depth and with the amount of work performed while the stack is unwound.
Practical rule: Use exceptions for rare error conditions, not for loops, parsing data that is expected to be invalid, or normal control flow. When an event is expected to occur frequently, prefer an explicit check, or a special return value.
Controlling exception profiling
Profiler UI
When the profiler is connected to the profiled application, the toolbar contains the following exception profiling controls:
| Toolbar Button | Description |
|
Start/Stop exception profiling. |
|
Clear exception profiling results. |
When exception profiling is started, previous results are cleared automatically.
Agent startup options
Exception profiling is enabled by default, but this can be adjusted with the following agent startup options:
-
exceptions=onImmediately start the exception profiling. This is the default mode. -
exceptions=offDo not immediately start the exception profiling that can instead be started later in runtime. -
exceptions=disableFully disable exception profiling and totally eliminate related overhead. The exception profiling will not be available.
HTTP API
For users requiring remote control or automation within their profiling workflows, YourKit .NET Profiler offers control over the exception profiling through HTTP API endpoints. The documentation outlines startExceptionProfiling, stopExceptionProfiling and resetExceptionProfiling methods available for this purpose.
.NET API
The YourKit .NET Profiler also provides a
.NET API
for deep integration with .NET applications.
The YourKit.Profiler.Api.Controller
includes methods for starting,
stopping, and resetting the exception profiling, similar to the toolbar buttons.
Exceptions tab
Exception profiling results can be analyzed from different perspectives:
- Exception telemetry shows a graph of how many exceptions the application throws per second.
- Exception tree - All threads shows the stack traces where exceptions were thrown as a single combined tree.
- Exception tree - By thread shows the stack traces where exceptions were thrown, grouped by .NET thread.
- Flame graph of thrown exceptions.