Looks like a big improvement in theory, but the actual steps look excessive and very command line focused-- the articles makes it seem like it isn't supported by the IDE?
Hi, MSVC dev lead here. Yes, but also... sorta. SPGO leverages xperf which is a generic Windows performance recorder. Using built-in systems necessitates a translation layer to produce counts that are consumable by the compiler/linker.
MSVC's had instrumentation-based profile-guided optimizations (PGO) for decades, but even with substantial performance benefits there are plenty of folks that don't use it. Speaking to some larger development organizations, the key hurdles are all about instrumentation. The first is that another build configuration is a pain to maintain. A second hurdle is that the instrumented bits are extremely slow: tests count collection can take a long time to run, and in some code bases you end up profiling the wrong code (if there's a lot of timeouts, or dropped frames, etc... that's what gets hyper-optimized).
With those issues in mind, SPGO is far more attractive alternative. There's no instrumentation build: you're profiling on your shipping, fully optimized (LTCG), binaries. Just build your release binaries with /SPGO, then focus profiling efforts on running xperf to gather counts to focus optimization decisions to the hot code paths.
Don't get me wrong, I love and appreciate all the effort put into optimizations and features like this; I was more pointing out that "dramatically easier" in my mind would be something closer to the existing performance profiler UI :)
However, no matter how I try, I always get an Error parsing test.etl error message when I invoke SPTAggregate.exe /binary test.exe /etl test.etl test.spt command.
If I try to manually execute the xperf command SPTAggregate prints, nothing happens - no error messages, no output files.
Are there any diagnostic steps that I can perform to find the cause of the error?
For teams adopting SPGO incrementally, there is also a linker option to avoid penalizing functions that lack profile data, compiling them with standard LTCG optimizations instead. This is particularly useful during early adoption when profile coverage is still growing.
What is the name of this option? It seems like SPGO changes the way profile info is collected, but then uses the same PGO engine used by "traditional" PGO: when profile coverage is small, it compiles "profiled functions for speed and all other functions for size".
This was the reason we stopped using "traditional" PGO in the past. For example, no matter how we tried, we could not force it to optimize the application startup code. By definition it executes once and was pessimized by optimizer if we tried to compile a binary with PGO.
If there is an option to tell the compiler "optimize profiled functions for speed and use traditional LTCG mode for the rest", this would be awesome. However, I cannot find such option in linker command-line reference guide.
Several folks have asked, so I'll give the special linker option to compile functions with little or no profile data as if it was a non-SPGO compile. That is, if you specified -O2 on a function, it will remain so if "cold". This is a linker option:
8
u/FrogNoPants May 20 '26 edited May 20 '26
Looks like a big improvement in theory, but the actual steps look excessive and very command line focused-- the articles makes it seem like it isn't supported by the IDE?
14
u/Kronikarz May 20 '26
Sure...
6
u/barfyus May 20 '26
This article misses important information (like required xperf configuration and conversion from ETL to SPT format).
There is a Sample Profile-guided optimization tutorial article which provides more information.
However, no matter how I try, I always get an
Error parsing test.etlerror message when I invokeSPTAggregate.exe /binary test.exe /etl test.etl test.sptcommand.If I try to manually execute the xperf command SPTAggregate prints, nothing happens - no error messages, no output files.
Are there any diagnostic steps that I can perform to find the cause of the error?
3
u/barfyus May 21 '26
What is the name of this option? It seems like SPGO changes the way profile info is collected, but then uses the same PGO engine used by "traditional" PGO: when profile coverage is small, it compiles "profiled functions for speed and all other functions for size".
This was the reason we stopped using "traditional" PGO in the past. For example, no matter how we tried, we could not force it to optimize the application startup code. By definition it executes once and was pessimized by optimizer if we tried to compile a binary with PGO.
If there is an option to tell the compiler "optimize profiled functions for speed and use traditional LTCG mode for the rest", this would be awesome. However, I cannot find such option in linker command-line reference guide.