-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reason I'm asking is because it sounds like we would probably only want "any" or "noDuplicates"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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).
Yeah, looks like it doesn't work on Linux. Before:
After:
For comparison, on Windows:
|
Rolled back the Linux portion and file #83375 for tracking :(. |
/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
]]>
<Exec Command="! "$(CppLinker)" -fuse-ld=gold -Wl,--icf=all 2>&1 | grep -q unrecognized"
Condition="'$(UseLlvmLinker)' != 'true' and '$(_targetOS)' == 'linux'"
IgnoreExitCode="true"
StandardOutputImportance="Low">
<Output TaskParameter="ExitCode" PropertyName="_GoldLinkerSupportedExitCode" />
</Exec>
<ItemGroup>
<LinkerArg Include="-fuse-ld=gold" Condition="'$(_GoldLinkerSupportedExitCode)' == '0'" />
<LinkerArg Include="-Wl,--icf=all" Condition="'$(_GoldLinkerSupportedExitCode)' == '0' or '$(UseLlvmLinker)' == 'true'" />
</ItemGroup> |
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 |
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. 🙂 |
@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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
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