Open deepak1556 opened 1 year ago
Couple of gotchas:
1) Prebuilt profiling runtime binaries (libclang_rt.profile-<arch>.a)
are not available for Linux arm64, Linux armhf and Windows arm64 from the chromium source tree. Although it is possible to build them from source, it will take considerable changes to the MS Electron build pipeline which is outside the scope of current phase for this experiment. We will skip instrumenting the corresponding VSCode builds for sake of simplicity.
2) Profiles are stored for each process from a file pool (which is currently set to 4 for child processes, ref: https://bugs.chromium.org/p/chromium/issues/detail?id=1059335) and one separate file is used for the main process. Also, the location of these files unless modified will write to the current working directory as seen in https://source.chromium.org/chromium/chromium/src/+/main:content/common/profiling_utils.cc;l=35-61. This is an issue when running product builds of VSCode which will try to write in the installation folder and causes the sandboxed child process to crash as seen below,
[57408:0112/184938.708273:ERROR:network_service_instance_impl.cc(470)] Network service crashed, restarting service.
[57408:0112/184938.709155:ERROR:profiling_utils.cc(87)] Opening file: /child_pool-0.profraw failed with -5
[57666:0112/184938.764001:ERROR:validation_errors.cc(106)] Invalid message: VALIDATION_ERROR_UNEXPECTED_NULL_POINTER (null field 1)
However, we can mitigate this by controlling the path via LLVM_PROFILE_FILE environment variable. I have decided to store the files in the user data directory, an example folder structure is as follows.
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
[x] Selfhost on the build and perform your everyday tasks, at the end of every run files with extension
*.profraw
will be generated in the user data directory underPGO_Profiles
folder.[x] :runner: At EOD, upload the generated
*.profraw
files to#proj-pgo
channelOptimization Phase
Building
.profraw
files into.profdata
using llvm-profdata script.profdata
using the following build flags