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
{{ message }}
Repository navigation
Lack of PGO probes in instrumented builds of libcoreclr #124141
When building coreclr with --pgoinstrument, libcoreclr.so ends up with essentially no PGO instrumentation probes. The add_pgo(coreclr) call in src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt uses target_compile_options(PRIVATE), which only applies -flto -fprofile-instr-generate to the source files compiled directly into the coreclr shared library target - just mscoree.cpp and exports.cpp. The resulting library has very few probes (20-100 over ~30 functions). The vast majority of the runtime code lives in static libraries (cee_wks, utilcode, coreclrpal, etc.) that are linked in already compiled, without instrumentation flags. This doesn't affect clrjit because the JIT compiles all its source files directly into the shared library target. Windows doesn't have this issue since this is a link time option.
Possible fix 1 (and I'd go a step further of cleanup and just move it to configure compiler at that point) is to define the compilation option globally
Possible fix 2 - walk the graph of deps when an add_pgo target is specified.
Fix 2 preserves behavior, but i'm not sure this complexity is buying us much. These builds mostly just get used for training and picking partial sets is not something I think gives us any benefit. After change 1, I see coreclr having ~5.1k probes. With the second, I see it have around 4.7k.
Fix 2 preserves behavior, but i'm not sure this complexity is buying us much. These builds mostly just get used for training and picking partial sets is not something I think gives us any benefit. After change 1, I see coreclr having ~5.1k probes. With the second, I see it have around 4.7k.
Push what you think is best and have us react there.
Possible fix 1 (and I'd go a step further of cleanup and just move it to configure compiler at that point) is to define the compilation option globally
I think this is the right option.
Ideally, we would get the PGO data for all native binaries that we ship, including e.g. System.Compression.Native.so.
@davidwrighton I wonder if this contributes to the TP issues you see in #123830, maybe the newly split off files no longer get handled via -flto? It seems odd in your PR the TP is so much worse on Linux than Windows.
Instrumentation level: Front-end
Total functions: 23033
Maximum function count: 371612116
Maximum internal block count: 310247889
Total number of blocks: 157560
Total count: 12753922631
Detailed summary:
1 blocks (0.00%) with count >= 371612116 account for 1% of the total counts.
4 blocks (0.00%) with count >= 283031649 account for 10% of the total counts.
44 blocks (0.03%) with count >= 17350575 account for 20% of the total counts.
146 blocks (0.09%) with count >= 10104082 account for 30% of the total counts.
310 blocks (0.20%) with count >= 6280439 account for 40% of the total counts.
570 blocks (0.36%) with count >= 3914974 account for 50% of the total counts.
990 blocks (0.63%) with count >= 2400265 account for 60% of the total counts.
1670 blocks (1.06%) with count >= 1463177 account for 70% of the total counts.
2939 blocks (1.87%) with count >= 693433 account for 80% of the total counts.
5766 blocks (3.66%) with count >= 276788 account for 90% of the total counts.
8997 blocks (5.71%) with count >= 133669 account for 95% of the total counts.
16800 blocks (10.66%) with count >= 24530 account for 99% of the total counts.
29359 blocks (18.63%) with count >= 2433 account for 99.9% of the total counts.
41190 blocks (26.14%) with count >= 265 account for 99.99% of the total counts.
50914 blocks (32.31%) with count >= 33 account for 99.999% of the total counts.
57816 blocks (36.69%) with count >= 7 account for 99.9999% of the total counts.
Binary IDs:
064dc193433b7a0a271535254baa81e2ba5afdf5
9ed95c5818bafa52e1d3f61b93b3a88d814c9246
Activity
hoyosjs commentedon Feb 8, 2026
Possible fix 1 (and I'd go a step further of cleanup and just move it to configure compiler at that point) is to define the compilation option globally
Possible fix 2 - walk the graph of deps when an add_pgo target is specified.
Both are in https://github.com/hoyosjs/runtime/commits/juhoyosa/fix-pgo
Fix 2 preserves behavior, but i'm not sure this complexity is buying us much. These builds mostly just get used for training and picking partial sets is not something I think gives us any benefit. After change 1, I see coreclr having ~5.1k probes. With the second, I see it have around 4.7k.
dotnet-policy-service commentedon Feb 8, 2026
Tagging subscribers to this area: @agocke, @dotnet/runtime-infrastructure
See info in area-owners.md if you want to be subscribed.
steveisok commentedon Feb 8, 2026
Push what you think is best and have us react there.
jkotas commentedon Feb 8, 2026
I think this is the right option.
Ideally, we would get the PGO data for all native binaries that we ship, including e.g. System.Compression.Native.so.
EgorBo commentedon Feb 9, 2026
Some time ago I tried to do that via #67820
AndyAyersMS commentedon Feb 11, 2026
@davidwrighton I wonder if this contributes to the TP issues you see in #123830, maybe the newly split off files no longer get handled via
-flto? It seems odd in your PR the TP is so much worse on Linux than Windows.dotnet-policy-service commentedon Apr 13, 2026
Tagging subscribers to this area: @dotnet/runtime-infrastructure
See info in area-owners.md if you want to be subscribed.
3 remaining items
EgorBo commentedon Jun 25, 2026
Let's keep it open till we get a confirmation libcoreclr is optimized with PGO
hoyosjs commentedon Jul 13, 2026
This is currently stuck - dotnet pgo crashes on arm64 during training
EgorBo commentedon Jul 13, 2026
@hoyosjs do you mean because of #128412 or for unknown reasons?
hoyosjs commentedon Jul 13, 2026
I don't think it's related - but it's blocking training. So we never got data.
Fix PGO instrumentation for libcoreclr.so static libraries (#128412)
hoyosjs commentedon Aug 6, 2026
On linux x64:
hoyosjs commentedon Aug 6, 2026
triggered #131916 that is the first one to bring these:
cc: @jkotas @AndyAyersMS @EgorBo