Skip to content

Commit 3f00b29

Browse files
committed
Add conceptual information related to call tree views in the profiler
1 parent 2c326fb commit 3f00b29

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

docs/profiling/cpu-usage.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ For more information on using the Flame graph, see [Identify hot paths with Flam
132132

133133
### <a name="BKMK_The_CPU_Usage_call_tree"></a> CPU Usage call tree
134134

135-
To view the call tree, select the parent node in the report. By default, the **CPU Usage** page opens to the **Caller/Callee** view. In the **Current View** dropdown, select **Call Tree**.
135+
To view the call tree, select the parent node in the report. By default, the **CPU Usage** page opens to the **Caller/Callee** view. In the **Current View** dropdown, select **Call Tree**. For help understanding data in the call tree, see [Understanding the call tree](#understanding-the-call-tree).
136136

137137
You can click the **Expand Hot Path** and **Show Hot Path** buttons to see the function calls that use the highest percentage of the CPU in the call tree view.
138138

@@ -191,7 +191,7 @@ To find a function name you're looking for, use the search box. Hover over the s
191191
![Screenshot that shows Search for nested external code.](../profiling/media/vs-2019/cpu-use-wt-show-external-code-too-wide-found.png "Search for nested external code")
192192
::: moniker-end
193193

194-
### <a name="BKMK_Asynchronous_functions_in_the_CPU_Usage_call_tree"></a> Asynchronous functions in the CPU usage call tree
194+
#### <a name="BKMK_Asynchronous_functions_in_the_CPU_Usage_call_tree"></a> Asynchronous functions in the CPU usage call tree
195195

196196
When the compiler encounters an asynchronous method, it creates a hidden class to control the method's execution. Conceptually, the class is a state machine. The class has compiler-generated functions that asynchronously call the original methods, and the callbacks, scheduler, and iterators needed to run them. When a parent method calls the original method, the compiler removes the method from the execution context of the parent, and runs the hidden class methods in the context of the system and framework code that controls app execution. The asynchronous methods are often, but not always, executed on one or more different threads. This code appears in the **CPU Usage** call tree as children of the **[External Code]** node immediately below the top node of the tree.
197197

@@ -216,7 +216,22 @@ Expand the generated methods to show what's going on:
216216
- `MainPage::<GetNumberAsync>b__b` shows the activity of the tasks that call `GetNumber`.
217217
::: moniker-end
218218

219+
#### Understanding the call tree
220+
221+
Sometimes, the call paths that appear in the **Call Tree** view for CPU Usage and Instrumentation tools may look different than you expect. To interpret the data you're seeing in the call tree, it helps to understand the common reasons for these differences. For example:
222+
223+
- Release builds perform many optimizations such as inline function calls. Inline functions don't appear in the call tree. In some cases, release build optimizations may also generate unexpected code that appears in the call tree.
224+
225+
- Asynchronous functions execute on their own thread independent of the call path, and they normally appear in a separate node.
226+
227+
::: moniker range=">=vs-2022"
228+
For Instrumentation, you can [configure options to view .NET async calls](../profiling/instrumentation.md#async-calls-in-the-instrumentation-call-tree-net) in a more intuitive way, within the call path where the async call was made.
229+
::: moniker-end
230+
231+
- For sampling (CPU Usage only), functions that execute very quickly may not get sampled, in which case these functions don't appear in the call tree.
232+
219233
::: moniker range=">=vs-2022"
234+
220235
### Analyze multi-process performance
221236

222237
Starting in Visual Studio 2022 version 17.13, you can analyze multi-process data in the CPU Usage tool. This makes it easier to analyzer performance for multi-process apps such as .NET Aspire. This features allows you to distinguish and analyze CPU utilization across processes within a single session, which provides clearer insights into resource consumption.

docs/profiling/instrumentation.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ Here's more information on the column values:
103103

104104
- **Module** The name of the module containing the function.
105105

106+
For help understanding data in the call tree, see [Understanding the call tree](../profiling/cpu-usage.md#understanding-the-call-tree).
107+
106108
### Async calls in the Instrumentation call tree (.NET)
107109

108110
Starting in Visual Studio 2022 version 17.13 Preview 2, views representing a visual call tree nest .NET asynchronous calls under the functions where the asynchronous call was made, making it easier to trace the execution flow within a single, unified stack trace. This can help you quickly identify performance bottlenecks.

0 commit comments

Comments
 (0)