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: content/learning-paths/laptops-and-desktops/win_profile_guided_optimisation/_index.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,13 +6,13 @@ minutes_to_complete: 30
6
6
who_is_this_for: This is an introductory topic for software developers who want to optimize C++ application performance on Windows on Arm using Profile-Guided Optimization (PGO).
7
7
8
8
learning_objectives:
9
-
- Microbenchmark a function using Google Benchmark.
10
-
- Apply profile-guided optimization to build performance-tuned binaries for Windows on Arm.
11
-
- Measure and compare performance improvements from PGO-optimized builds.
9
+
- Microbenchmark a function using Google Benchmark
10
+
- Apply profile-guided optimization to build performance-tuned binaries for Windows on Arm
11
+
- Measure and compare performance improvements from PGO-optimized builds
12
12
13
13
prerequisites:
14
-
- Familiarity with C++ development and compiling programs from the command line.
15
-
- A Windows on Arm machine with [Visual Studio](/install-guides/vs-woa/) and the C++ desktop development tools installed.
14
+
- Familiarity with C++ development and compiling programs from the command line
15
+
- A Windows on Arm machine with [Visual Studio](/install-guides/vs-woa/) and the C++ desktop development tools installed
Copy file name to clipboardExpand all lines: content/learning-paths/laptops-and-desktops/win_profile_guided_optimisation/how-to-1.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,6 +40,6 @@ Additionally, the process requires extra build steps, which can increase compile
40
40
41
41
PGO might not be ideal for early-stage development or applications with highly variable or unpredictable usage patterns.
42
42
43
-
## What you've learned and what's next
43
+
## What you've accomplished and what's next
44
44
45
45
You now understand what PGO is, how it improves performance through code layout and inlining optimizations, and when to apply it. In the next section, you'll learn about Google Benchmark, the tool you'll use to measure these performance improvements.
Copy file name to clipboardExpand all lines: content/learning-paths/laptops-and-desktops/win_profile_guided_optimisation/how-to-2.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,7 @@ BENCHMARK(BM_StringCreation);
34
34
BENCHMARK_MAIN();
35
35
```
36
36
37
-
## Control benchmarks with Google Benchmark filters
37
+
## Control benchmark execution
38
38
39
39
Google Benchmark provides tools to ensure accurate measurements by preventing unintended compiler optimizations and allowing flexible benchmark selection.
40
40
@@ -48,6 +48,6 @@ When you have multiple benchmarks, you can run a specific subset using the `--be
48
48
49
49
Filtering eliminates the need to repeatedly comment out lines of source code when you want to focus on specific benchmarks.
50
50
51
-
## What you've learned
51
+
## What you've accomplished and what's next
52
52
53
53
You now understand how to write basic benchmarks with Google Benchmark, use `benchmark::DoNotOptimize` to prevent unwanted compiler optimizations, and filter benchmark execution with command-line options. In the next section, you'll install Google Benchmark and create a baseline benchmark to measure division performance on Windows on Arm.
Copy file name to clipboardExpand all lines: content/learning-paths/laptops-and-desktops/win_profile_guided_optimisation/how-to-3.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -58,7 +58,7 @@ BENCHMARK(baseDiv)->Arg(1500)->Unit(benchmark::kMicrosecond); // value of 1500 i
58
58
BENCHMARK_MAIN();
59
59
```
60
60
61
-
## Compile and run the baseline benchmark with MSVC
61
+
## Compile the baseline benchmark with MSVC
62
62
63
63
Open an **ARM64 Native Tools Command Prompt** from the Windows Start menu and start PowerShell:
64
64
@@ -107,6 +107,6 @@ baseDiv/1500 7.90 us 7.90 us 88512
107
107
108
108
The warning appears because the Google Benchmark library was built in debug mode, but it doesn't affect the validity of the measurements for this example.
109
109
110
-
## What you've accomplished
110
+
## What you've accomplished and what's next
111
111
112
112
You've set up Google Benchmark on Windows on Arm, created a division-heavy benchmark, and established a baseline performance measurement of 7.90 microseconds. This baseline gives you a clear reference point to measure the impact of Profile-Guided Optimization. In the next section, you'll apply PGO to this code and measure the performance improvement.
Copy file name to clipboardExpand all lines: content/learning-paths/laptops-and-desktops/win_profile_guided_optimisation/how-to-4.md
+6-4Lines changed: 6 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,8 @@ weight: 5
6
6
layout: learningpathall
7
7
---
8
8
9
+
## Overview
10
+
9
11
Now that you have a baseline benchmark, you're ready to apply Profile-Guided Optimization. The PGO process involves three steps: build an instrumented binary, run it to collect profile data, and rebuild with optimizations based on that data.
This command uses several important compiler and linker options. The `/O2` flag creates fast code, while `/GL` enables whole program optimization. The `/GENPROFILE` linker option generates a `.pgd` file for PGO, and `/LTCG` specifies link time code generation. The `/PGD` option specifies the database file where profile data will be stored.
28
30
29
-
## Collect profile data
31
+
## Collect PGO profile data on Windows on Arm
30
32
31
33
Run the instrumented binary to generate profile data:
32
34
@@ -36,7 +38,7 @@ Run the instrumented binary to generate profile data:
36
38
37
39
This execution creates profile data files (typically with a `.pgc` extension) in the same directory. The profile data captures information about which code paths execute most frequently and how the program behaves at runtime.
38
40
39
-
## Rebuild with optimizations
41
+
## Rebuild with PGO optimizations
40
42
41
43
Now recompile the program using the `/USEPROFILE` flag to apply optimizations based on the collected data:
The `/USEPROFILE` linker option instructs the linker to enable PGO with the profile generated during the previous run. The compiler can now make informed decisions about code layout, inlining, and other optimizations based on actual runtime behavior.
48
50
49
-
## Measure the improvement
51
+
## Measure PGO performance gains
50
52
51
53
Run the optimized binary to see the performance improvement:
52
54
@@ -80,4 +82,4 @@ The compiler used the profile data to determine that the divisor was consistentl
80
82
81
83
## What you've accomplished
82
84
83
-
You've applied PGO to reduce execution time by 64% on a division-heavy benchmark. You completed the full PGO workflow: instrument, profile, and optimize. Apply this same technique to performance-critical sections of your own code to achieve similar gains on Windows on Arm.
85
+
You've applied PGO to reduce execution time by 64% on a division-heavy benchmark. You completed the full PGO workflow: instrument, profile, and optimize. Apply this same technique to performance-critical sections of your own code to achieve similar gains on Windows on Arm.
0 commit comments