Uh oh!
There was an error while loading. Please reload this page.
Emit GC info into a COMDAT section - #83371
Conversation
Saves 3.14% on BasicWebApi. 🤯 We run linker with COMDAT folding enabled. Generating this data into COMDAT foldable section allows linker to deduplicate these.
ghost
commented
Mar 14, 2023
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas Issue DetailsSaves 3.14% on BasicWebApi. 🤯 We run linker with COMDAT folding enabled. Generating this data into COMDAT foldable section allows linker to deduplicate these. Cc @dotnet/ilc-contrib
|
| ObjectNodeSection section = ObjectNodeSection.XDataSection; | ||
| if (ShouldShareSymbol(node)) | ||
| section = GetSharedSection(section, _sb.ToString()); | ||
| ObjectNodeSection section = GetSharedSection(ObjectNodeSection.XDataSection, _sb.ToString()); |
There was a problem hiding this comment.
It looks like LLVM defines a number of different SelectionKinds for COMDAT sections, but I can't see where define any. The LLVM ones look like this:
There was a problem hiding this comment.
Reason I'm asking is because it sounds like we would probably only want "any" or "noDuplicates"
There was a problem hiding this comment.
It appears to do the right thing on Windows, but I haven't checked Linux (hoped I would see it in the CI results).
If it doesn't work on Linux, it's likely because of #77491. I'd back out the non-Windows portion of this change and file a bug to reap this benefit outside Windows in 8.0 (it would be more work than just a one-liner that I randomly tried).
MichalStrehovsky
commented
Mar 14, 2023
Yeah, looks like it doesn't work on Linux. Before: After: For comparison, on Windows: |
MichalStrehovsky
commented
Mar 14, 2023
Rolled back the Linux portion and file #83375 for tracking :(. |
MichalStrehovsky
commented
Mar 14, 2023
/azp run runtime-extra-platforms |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Seems like Introspection in <![CDATA[ Testing: if ! cc -fuse-ld=gold -Wl,--icf=all 2>&1 | grep -q unrecognized; then echo "yes, gold linker is available" fi]]>
<ExecCommand="! "$(CppLinker)" -fuse-ld=gold -Wl,--icf=all 2>&1 | grep -q unrecognized"Condition="'$(UseLlvmLinker)' != 'true' and '$(_targetOS)' == 'linux'"IgnoreExitCode="true"StandardOutputImportance="Low">
<OutputTaskParameter="ExitCode"PropertyName="_GoldLinkerSupportedExitCode" />
</Exec>
<ItemGroup>
<LinkerArgInclude="-fuse-ld=gold"Condition="'$(_GoldLinkerSupportedExitCode)' == '0'" />
<LinkerArgInclude="-Wl,--icf=all"Condition="'$(_GoldLinkerSupportedExitCode)' == '0' or '$(UseLlvmLinker)' == 'true'" />
</ItemGroup> |
MichalStrehovsky
commented
Mar 15, 2023
Thanks for testing it out! I think this is only folding the native code within the executable. We don't generate code into separate sections unless Looks like what we want is
Is this something you'd be willing to contribute? I just tried |
am11
commented
Mar 15, 2023
Ah, I haven't looked too closely. I found the difference only with Perhaps we would see more differences with lld if we start emitting this section? Other linkers apparently will optimize using this section in the future and we will automatically opt-in without additional work (bfd: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105625, mold: rui314/mold#484).
Sounds great, I will take a look. 🙂 |
MichalStrehovsky
commented
Apr 25, 2023
@dotnet/ilc-contrib could someone have a look? This is a good saving on Windows. We'll have to investigate how to translate this to Linux but that's tracked in #83375. It's likely object writer work around COMDATs. |
Saves 3.14% on BasicWebApi. 🤯
We run linker with COMDAT folding enabled. Generating this data into COMDAT foldable section allows linker to deduplicate these.
Cc @dotnet/ilc-contrib