From Profile Guided Optimization
Profile information enables better optimization. For example, knowing that a branch is taken very frequently helps the compiler make better decisions when ordering basic blocks. Knowing that a function foo is called more frequently than another function bar helps the inliner. Optimization levels -O2 and above are recommended for use of profile guided optimization.
Clang supports profile guided optimization with two different kinds of profiling. A sampling profiler can generate a profile with very low runtime overhead, or you can build an instrumented version of the code that collects more detailed profile information. Both kinds of profiles can provide execution counts for instructions in the code and information on branches taken and function invocation.
Regardless of which kind of profiling you use, be careful to collect profiles by running your code with inputs that are representative of the typical behavior. Code that is not exercised in the profile will be optimized as if it is unimportant, and the compiler may make poor optimization choices for code that is disproportionately used while profiling.
Chromium build configuration has opt-in support for PGO https://chromium.googlesource.com/chromium/src.git/+/refs/heads/main/docs/pgo.md. The issue is to track the effort of optimizing the Electron runtime with PGO for VSCode. This will be a multi-step process and initially some manual steps are also involved, we will investigate automating the whole flow if the results are satisfying.
For this experiment, we are using the instrumented version to collect the profile. Steps involved are as follows,
Instrumentation Phase
Building
chrome_pgo_phase = 1
enable_resource_allowlist_generation = false
Running
NB: Builds from branch robo/explore_pgo will always reflect latest changes from main, only difference is the instrumented runtime build, so it will not affect your everyday use.
NB: There is no limit on the number of days to selfhost on this build during the experiment. Scheduled nightly updates will be available.
Optimization Phase
Building
chrome_pgo_phase = 2
pgo_data_path = {path-to-the-profdata}
Chromium build configuration has opt-in support for PGO https://chromium.googlesource.com/chromium/src.git/+/refs/heads/main/docs/pgo.md. The issue is to track the effort of optimizing the Electron runtime with PGO for VSCode. This will be a multi-step process and initially some manual steps are also involved, we will investigate automating the whole flow if the results are satisfying.
For this experiment, we are using the instrumented version to collect the profile. Steps involved are as follows,
Instrumentation Phase
Building
Running
Selfhost on the build and perform your everyday tasks, at the end of every run files with extension
*.profrawwill be generated in the user data directory underPGO_Profilesfolder.🏃 At EOD, upload the generated
*.profrawfiles to#proj-pgochannelOptimization Phase
Building
.profrawfiles into.profdatausing llvm-profdata script.profdatausing the following build flags