Skip to content

Commit 928e7e8

Browse files
Up
1 parent b9b7e95 commit 928e7e8

5 files changed

Lines changed: 16 additions & 14 deletions

File tree

content/learning-paths/laptops-and-desktops/win_profile_guided_optimisation/_index.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ minutes_to_complete: 30
66
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).
77

88
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
1212

1313
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
1616

1717
author: Tom Dunkle
1818

content/learning-paths/laptops-and-desktops/win_profile_guided_optimisation/how-to-1.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ Additionally, the process requires extra build steps, which can increase compile
4040

4141
PGO might not be ideal for early-stage development or applications with highly variable or unpredictable usage patterns.
4242

43-
## What you've learned and what's next
43+
## What you've accomplished and what's next
4444

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

content/learning-paths/laptops-and-desktops/win_profile_guided_optimisation/how-to-2.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ BENCHMARK(BM_StringCreation);
3434
BENCHMARK_MAIN();
3535
```
3636
37-
## Control benchmarks with Google Benchmark filters
37+
## Control benchmark execution
3838
3939
Google Benchmark provides tools to ensure accurate measurements by preventing unintended compiler optimizations and allowing flexible benchmark selection.
4040
@@ -48,6 +48,6 @@ When you have multiple benchmarks, you can run a specific subset using the `--be
4848

4949
Filtering eliminates the need to repeatedly comment out lines of source code when you want to focus on specific benchmarks.
5050

51-
## What you've learned
51+
## What you've accomplished and what's next
5252

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

content/learning-paths/laptops-and-desktops/win_profile_guided_optimisation/how-to-3.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ BENCHMARK(baseDiv)->Arg(1500)->Unit(benchmark::kMicrosecond); // value of 1500 i
5858
BENCHMARK_MAIN();
5959
```
6060
61-
## Compile and run the baseline benchmark with MSVC
61+
## Compile the baseline benchmark with MSVC
6262
6363
Open an **ARM64 Native Tools Command Prompt** from the Windows Start menu and start PowerShell:
6464
@@ -107,6 +107,6 @@ baseDiv/1500 7.90 us 7.90 us 88512
107107

108108
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.
109109

110-
## What you've accomplished
110+
## What you've accomplished and what's next
111111

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

content/learning-paths/laptops-and-desktops/win_profile_guided_optimisation/how-to-4.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ weight: 5
66
layout: learningpathall
77
---
88

9+
## Overview
10+
911
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.
1012

1113
## Build instrumented binary with MSVC
@@ -26,7 +28,7 @@ cl /O2 /GL /D BENCHMARK_STATIC_DEFINE /I "$VCPKG\include" /Fe:div_bench.exe div_
2628

2729
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.
2830

29-
## Collect profile data
31+
## Collect PGO profile data on Windows on Arm
3032

3133
Run the instrumented binary to generate profile data:
3234

@@ -36,7 +38,7 @@ Run the instrumented binary to generate profile data:
3638

3739
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.
3840

39-
## Rebuild with optimizations
41+
## Rebuild with PGO optimizations
4042

4143
Now recompile the program using the `/USEPROFILE` flag to apply optimizations based on the collected data:
4244

@@ -46,7 +48,7 @@ cl /O2 /GL /D BENCHMARK_STATIC_DEFINE /I "$VCPKG\include" /Fe:div_bench_opt.exe
4648

4749
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.
4850

49-
## Measure the improvement
51+
## Measure PGO performance gains
5052

5153
Run the optimized binary to see the performance improvement:
5254

@@ -80,4 +82,4 @@ The compiler used the profile data to determine that the divisor was consistentl
8082

8183
## What you've accomplished
8284

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

Comments
 (0)