The thread profiler is a low-impact profiling tool that can be used in production to identify bottlenecks in an application. It works by periodically (100ms) capturing the stack trace of each thread for a specified duration. At the end of the specified duration, the stack traces are aggregated to build a tree. The call count in the tree corresponds to the number of times that function was present in the stack traces under the same context.
Although the call tree cannot capture the entire execution, a large enough sample can be a good representation of the application behavior. This provides insights into the "hot" functions of the app where most of the time is spent. With this scope, entries sampled less than 0.05% are omitted.
This feature is available only for specific agents and versions:
- Java: Agent versions 1.2.004.6 or higher
- Framework: Agent versions 188.8.131.52 or higher
- .NET Core 2.0: Agent versions 8.3.360.0 or higher (Windows only)
- Linux: .NET Core 3.0 or higher and agent versions 8.23 or higher
- Python: Agent versions 1.7.0 or higher
- Ruby: Agent versions 3.5.5 or higher
The thread profiler feature is enabled by default. You also may be able to turn it on or off in your agent configuration file:
- NET: You cannot disable the thread profiler with .NET apps.
When enabled, you can view the thread profiler from our user interface:
- Go to one.newrelic.com > APM > (select an app) > Events > Thread profiler.
- Select the host you want to run the profiler on.
- Set the duration for the profiling session.
- Select Start profiler.
This triggers the agent to start the thread profiler during the next harvest cycle (every one minute) and capture data for the specified duration. We record thread backtraces whether or not they are in a runnable state at the time the sample is taken. Threads that are sleeping or blocked on IO may appear in the call tree.
one.newrelic.com > APM > (select an app) > Events > Thread profiler: Use this page to define the settings for the thread profiler duration and to view the results.
After the profiler finishes running, the agent will report the profile data. The call tree automatically appears on the Thread profiler page. The percentages in the call tree represent the percentage of thread backtrace samples in which each call path appeared during the profiling session. The data collection started at the PROFILE COLLECTED time.
The page color-codes the tree results:
- Red: Percentages greater than 30%
- Yellow: Percentages greater than 10%
- Black: Percentages less than 10%
If you want to...
Change how the thread profile information appears
Select your choices of available options in the Tree settings, and select Refresh tree.
Change how much information appears
Select the Expand or Collapse options above the call tree, or select the name or arrow on any line in the call tree.
View summary information about any line in the call tree
Mouse over the line.
Email the thread profile results to others
Select Share this profile.
Start another session or view a different thread profile
Select Back to all profiles.
Depending on which agent you use, the thread profiling feature has additional considerations.