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-template-view.md
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -111,7 +111,7 @@ Template instantiation time collection is off by default to minimize build overh
111
111
112
112
## Run Build Insights to get template instantiation data
113
113
114
-
From the main menu, select **Build** > **Run Build Insights on Selection** > **Rebuild**. You can also right-click a project in Solution Explorer and select **Run Build Insights** > **Rebuild**. Choose **Rebuild** instead of **Build** to measure the build time for the entire project.
114
+
From the main menu, select **Build** > **Run Build Insights on Solution** > **Rebuild**. You can also right-click a project in Solution Explorer and select **Run Build Insights** > **Rebuild**. Choose **Rebuild** instead of **Build** to measure the build time for the entire project.
115
115
116
116
:::image type="content" source="./media/build-insights-rebuild-project.png" alt-text="Screenshot of the main menu with Run Build Insights on Selection > Rebuild selected.":::
117
117
@@ -126,7 +126,7 @@ The **Templates** view lists the template instantiations that contributed signif
126
126
-**Translation Unit** shows the source files where each template instantiation happens. Different files can cause the same template instantiation if they include the same header with the template definition.
127
127
-**Instantiation File Name** shows where the template is defined.
128
128
129
-
:::image type="complex" source="./media/templates-view-before-fix.png" alt-text="Screenshot of the Build Insights Templates view showing expensive template instantiations.":::
129
+
:::image type="complex" source="./media/templates-view-before-fix.png" alt-text="Screenshot of the Build Insights Templates view showing expensive template instantiations." lightbox="./media/templates-view-before-fix.png":::
130
130
The Templates view shows two template instantiations of struct S3 taking most (79.448 percent) of the build time. The Translation Unit column shows that both LargeValue.cpp and SmallValue.cpp are affected. The build time is 4.066 seconds.
131
131
:::image-end:::
132
132
@@ -136,7 +136,7 @@ The Templates view shows two template instantiations of struct S3 taking most (7
136
136
137
137
### Understanding Templates view results
138
138
139
-
When interpreting Templates view results, consider the following:
139
+
To interpret the **Templates** view results:
140
140
141
141
-**Empty view**: If nothing shows up in the **Templates** view, template instantiations don't dominate your build time. That's good news because your templates aren't a build bottleneck.
142
142
-**Duplicate instantiations**: If the same template instantiation appears multiple times across different translation units, different source files are causing the same expensive instantiation. This is often the biggest optimization opportunity.
@@ -145,9 +145,9 @@ When interpreting Templates view results, consider the following:
145
145
146
146
## Improve build time by optimizing template instantiations
147
147
148
-
In this example, two template instantiations of `S3` take 79 percent of the build time. The **Translation Unit** column shows that both `SmallValue.cpp` and `LargeValue.cpp` cause this template instantiation.
148
+
In the example, two template instantiations of `S3` take 79 percent of the build time. The **Translation Unit** column shows that both `SmallValue.cpp` and `LargeValue.cpp` cause this template instantiation.
149
149
150
-
Because the **Instantiation File Name** and the **Specialization Name** are the same for both entries, there's one expensive template instantiation that affects both source files. That's why the time for each of the two template instantiations is roughly equal. Including `Templates.h` in both source files causes one template instantiation to add significant time to the build.
150
+
The **Instantiation File Name** and the **Specialization Name** are the same for both entries, which means one expensive template instantiation that affects both source files. That's why the time for each of the two template instantiations is roughly equal. Including `Templates.h` in both source files causes one template instantiation to add significant time to the build.
151
151
152
152
From the **Specialization Name** column, the expensive instantiation is `S3<std::make_index_sequence<1000>>`, which is instantiated in this code in `Templates.h`:
153
153
@@ -158,7 +158,7 @@ inline size_t LargeValue()
158
158
};
159
159
```
160
160
161
-
Here are three main ways to decrease the cost of template instantiations.
161
+
There are three main ways to decrease the cost of template instantiations.
162
162
163
163
### Remove unused templates
164
164
@@ -170,7 +170,7 @@ Consider removing include directives that bring in unnecessary template instanti
170
170
171
171
In this example, rely on the third approach: move the definition that causes the expensive template instantiation to a source file.
172
172
173
-
Because `LargeValue.cpp` is the only source file that calls `LargeValue()`, move the definition to `LargeValue.cpp`. This change prevents the template instantiation from happening in every translation unit that includes `Templates.h`. Remove the current definition of `LargeValue()` from `Templates.h` and replace it with a declaration:
173
+
Because `LargeValue.cpp` is the only source file that calls `LargeValue()`, move the definition to `LargeValue.cpp`. This change prevents the template instantiation from happening in every file that includes `Templates.h`. Remove the current definition of `LargeValue()` from `Templates.h` and replace it with a declaration:
174
174
175
175
```cpp
176
176
size_tLargeValue();
@@ -189,7 +189,7 @@ Rebuild the project and run Build Insights again from the main menu. Select **Bu
189
189
190
190
The build time decreases. While the template instantiation of `S3` still contributes to the build time, including only necessary template instantiations cuts the build time nearly in half. The count of `S3` instantiations is now one instead of two.
191
191
192
-
:::image type="complex" source="./media/templates-view-after-fix.png" alt-text="Screenshot of the Build Insights Templates view after optimization. The view shows reduced template instantiation time.":::
192
+
:::image type="complex" source="./media/templates-view-after-fix.png" alt-text="Screenshot of the Build Insights Templates view after optimization. The view shows reduced template instantiation time." lightbox="./media/templates-view-after-fix.png":::
193
193
The Templates view now shows only one instantiation of S3 instead of two, and the total build time is significantly less at 3.152 seconds.
194
194
:::image-end:::
195
195
@@ -208,7 +208,7 @@ For more advanced template optimization techniques, see [Build Throughput Series
208
208
## Tips
209
209
210
210
- 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.
211
-
- If you close the Build Insights window, reopen it by finding the `<dateandtime>.etl` file either where you specified it should be saved, or in your temporary folder. The `TEMP` Windows environment variable provides the path of your temporary files folder.
211
+
- If you close the Build Insights window, reopen it by finding the *dateandtime*.etl file either where you specified it should be saved, or in your temporary folder. The `TEMP` Windows environment variable provides the path of your temporary files folder.
212
212
- Drag columns to change the order of the columns. For example, you might want to move the **Wall Time Responsibility** column to the first column. You can add or hide columns by right-clicking the column header and selecting or deselecting the columns you want.
213
213
- The **Templates** view has a filter box to help you find a specific template instantiation. It does partial matches on the name you provide.
0 commit comments