Skip to content

Commit 3708c17

Browse files
Learn Build Service GitHub AppLearn Build Service GitHub App
authored andcommitted
Merging changes synced from https://github.com/MicrosoftDocs/cpp-docs-pr (branch live)
2 parents bfad37c + 876381f commit 3708c17

9 files changed

+249
-189
lines changed

docs/build-insights/toc.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ items:
66
- name: "Tutorials"
77
expanded: true
88
items:
9-
- name: "Troubleshoot function inlining on build time"
9+
- name: "Troubleshoot function inlining impact on build time"
1010
href: ../build-insights/tutorials/build-insights-function-view.md
11+
- name: "Troubleshoot template instantiation impact on build time"
12+
href: ../build-insights/tutorials/build-insights-template-view.md
1113
- name: "Troubleshoot header file impact on build time"
1214
href: ../build-insights/tutorials/build-insights-included-files-view.md
1315
- name: "Build Insights tips and tricks"

docs/build-insights/tutorials/build-insights-function-view.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
---
2-
title: "Troubleshoot function inlining on build time"
2+
title: "Troubleshoot function inlining impact on build time"
33
description: "Tutorial for how to use Build Insights function view to troubleshoot the impact of function inlining on build time in your C++ projects."
44
ms.date: 5/30/2024
55
helpviewer_keywords: ["C++ Build Insights", "inline function analysis", "build time analysis", "__forceinline analysis", "inlines analysis"]
66
ms.topic: troubleshooting-general
77
---
8-
# Troubleshoot function inlining on build time
8+
# Troubleshoot function inlining impact on build time
99

1010
Use Build Insights **Functions** view to troubleshoot the impact of function inlining on build time in your C++ projects.
1111

1212
## Prerequisites
1313

1414
- 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.
1616

1717
:::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.":::
1818
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
6161

6262
## Function view
6363

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.
6565

6666
:::image type="complex" source="./media/functions-view-before-fix.png" alt-text="Screenshot of the Build Insights Functions view file.":::
6767
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
8383
In the Function Name column, performPhysicsCalculations() is highlighted and marked with a fire icon.
8484
:::image-end:::
8585

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.
8787

8888
:::image type="complex" source="./media/functions-view-expanded.png" alt-text="Screenshot of the Build Insights Functions view with an expanded function.":::
8989
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)
106106
}
107107
```
108108
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.
110110
111111
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.
112112
@@ -128,8 +128,8 @@ Double-click, right-click, or press **Enter** while on a file in the **Functions
128128
129129
## Tips
130130
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.
133133
- 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.
134134
- 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.
135135
- 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

Comments
 (0)