You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/build-insights/tutorials/build-insights-function-view.md
+8-8Lines changed: 8 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,18 @@
1
1
---
2
-
title: "Troubleshoot function inlining on build time"
2
+
title: "Troubleshoot function inlining impact on build time"
3
3
description: "Tutorial for how to use Build Insights function view to troubleshoot the impact of function inlining on build time in your C++ projects."
4
4
ms.date: 5/30/2024
5
5
helpviewer_keywords: ["C++ Build Insights", "inline function analysis", "build time analysis", "__forceinline analysis", "inlines analysis"]
6
6
ms.topic: troubleshooting-general
7
7
---
8
-
# Troubleshoot function inlining on build time
8
+
# Troubleshoot function inlining impact on build time
9
9
10
10
Use Build Insights **Functions** view to troubleshoot the impact of function inlining on build time in your C++ projects.
11
11
12
12
## Prerequisites
13
13
14
14
- Visual Studio 2022 17.8 or greater.
15
-
- C++ Build insights is enabled by default if you install either the Desktop development with C++ workload or the Game development with C++ workload.
15
+
- C++ Build Insights is enabled by default if you install either the Desktop development with C++ workload or the Game development with C++ workload.
16
16
17
17
:::image type="complex" source="./media/installer-desktop-cpp-build-insights.png" alt-text="Screenshot of the Visual Studio Installer with the Desktop development with C++ workload selected.":::
18
18
The list of installed components is shown. C++ Build Insights is highlighted and is selected which means it's installed.
@@ -61,7 +61,7 @@ When the build finishes, an Event Trace Log (ETL) file opens. It's saved in the
61
61
62
62
## Function view
63
63
64
-
In the window for the ETL file, choose the **Functions** tab. It shows the functions that were compiled and the time it took to generate the code for each function. If the amount of code generated for a function is negligible, it won't appear in the list to avoid degrading build event collection performance.
64
+
In the window for the ETL file, choose the **Functions** tab. It shows the functions that were compiled and the time it took to generate the code for each function. If the amount of code generated for a function is negligible, it doesn't appear in the list to avoid degrading build event collection performance.
65
65
66
66
:::image type="complex" source="./media/functions-view-before-fix.png" alt-text="Screenshot of the Build Insights Functions view file.":::
67
67
In the Function Name column, performPhysicsCalculations() is highlighted and marked with a fire icon.
@@ -83,7 +83,7 @@ In this example, the `performPhysicsCalculations` function is taking the most ti
83
83
In the Function Name column, performPhysicsCalculations() is highlighted and marked with a fire icon.
84
84
:::image-end:::
85
85
86
-
Investigating further, by selecting the chevron before that function, and then sorting the **Forceinline Size** column from highest to lowest, we see the biggest contributors to the problem.
86
+
By selecting the chevron before that function, and then sorting the **Forceinline Size** column from highest to lowest, we see the biggest contributors to the problem.
87
87
88
88
:::image type="complex" source="./media/functions-view-expanded.png" alt-text="Screenshot of the Build Insights Functions view with an expanded function.":::
89
89
performPhysicsCalculations() is expanded and shows a long list of functions that were inlined inside it. There are multiple instances of functions such as complexOperation(), recursiveHelper(), and sin() shown. The Forceinline Size column shows that complexOperation() is the largest inlined function at 315 instructions. recursiveHelper() has 119 instructions. Sin() has 75 instructions, but there are many more instances of it than the other functions.
@@ -106,7 +106,7 @@ static __forceinline T factorial(int n)
106
106
}
107
107
```
108
108
109
-
Perhaps the overall cost of calling this function is insignificant compared to the cost of the function itself. Making a function inline is most beneficial when the time it takes to call the function (pushing arguments on the stack, jumping to the function, popping return arguments, and returning from the function) is roughly similar to the time it takes to execute the function, and when the function is called a lot. When that's not the case, there may be diminishing returns on making it inline. We can try removing the `__forceinline` directive from it to see if it helps the build time. The code for `power`, `sin()` and `cos()` is similar in that the code consists of a loop that will execute many times. We can try removing the `__forceinline` directive from those functions as well.
109
+
Perhaps the overall cost of calling this function is insignificant compared to the cost of the function itself. Making a function inline is most beneficial when the time it takes to call the function (pushing arguments on the stack, jumping to the function, popping return arguments, and returning from the function) is roughly similar to the time it takes to execute the function, and when the function is called a lot. When that's not the case, there may be diminishing returns on making it inline. We can try removing the `__forceinline` directive from it to see if it helps the build time. The code for `power`, `sin()`, and `cos()` is similar in that the code consists of a loop that executes many times. We can try removing the `__forceinline` directive from those functions as well.
110
110
111
111
We rerun Build Insights from the main menu by choosing **Build** > **Run Build Insights on Selection** > **Rebuild**. You can also right-click a project in the solution explorer and choose **Run Build Insights** > **Rebuild**. We choose **Rebuild** instead of **Build** to measure the build time for the entire project, as before, and not for just the few files may be dirty right now.
112
112
@@ -128,8 +128,8 @@ Double-click, right-click, or press **Enter** while on a file in the **Functions
128
128
129
129
## Tips
130
130
131
-
- You can **File** > **Save As** the ETL file to a more permanent location to keep a record of the build time. You can then compare it to future builds to see if your changes are improving build time.
132
-
- If you inadvertently close the Build Insights window, reopen it by finding the `<dateandtime>.etl` file in your temporary folder. The `TEMP` Windows environment variable provides the path of your temporary files folder.
131
+
- Use **File** > **Save As** to save the ETL file to a more permanent location to keep a record of the build time information. You can then compare it to future builds to see how your changes are improving things.
132
+
- If you close the Build Insights window, reopen it by finding the `<dateandtime>.etl` file in your temporary folder. The `TEMP` Windows environment variable provides the path of your temporary files folder.
133
133
- To dig into the Build Insights data with Windows Performance Analyzer (WPA), click the **Open in WPA** button in the bottom right of the ETL window.
134
134
- Drag columns to change the order of the columns. For instance, you may prefer moving the **Time** column to be the first column. You can hide columns by right-clicking on the column header and deselecting the columns you don't want to see.
135
135
- The **Functions** view provides a filter box to find a function that you're interested in. It does partial matches on the name you provide.
0 commit comments