Skip to content

Add ILLink file for ComputeSharp configuration - #532

Merged
Sergio0694 merged 5 commits into
mainfrom
dev/trim-computesharp-configuration
Jun 25, 2023
Merged

Sergio0694 merged 5 commits into
mainfrom
dev/trim-computesharp-configuration

Conversation

@Sergio0694

Copy link
Copy Markdown
Owner

Description

This PR adds an ILLink configuration file to trim the configuration flags (same as terrafx/terrafx.interop.windows#341). For some reason though this doesn't seem to be working — I'm getting the same exact 1.715 KB binary when building the CLI sample with NativeAOT on .NET 7 both with these changes, and removing that embedded resource entirely 🤔

@tannergooding @MichalStrehovsky am I missing something obvious here? 😅

@Sergio0694 Sergio0694 added the optimization 🚀 Performance improvement to existing APIs label Jun 24, 2023
@Sergio0694

Copy link
Copy Markdown
Owner Author

Diffs:

  • Default: 1.716 KB
  • Trimmed: 1.648 KB

Total: -68 KB (-4%), I'll take it! 🚀

@Sergio0694
Sergio0694 force-pushed the dev/trim-computesharp-configuration branch from b4edcbd to 33f01c2 Compare June 25, 2023 10:22
@Sergio0694
Sergio0694 merged commit a4c18a6 into main Jun 25, 2023
@Sergio0694
Sergio0694 deleted the dev/trim-computesharp-configuration branch June 25, 2023 11:22
<method signature="System.Boolean get_IsDeviceRemovedExtendedDataEnabled()" body="stub" value="false" feature="COMPUTESHARP_ENABLE_DEVICE_REMOVED_EXTENDED_DATA" featurevalue="false"/>
<method signature="System.Boolean get_IsDeviceRemovedExtendedDataEnabled()" body="stub" value="true" feature="COMPUTESHARP_ENABLE_DEVICE_REMOVED_EXTENDED_DATA" featurevalue="true"/>

<!-- COMPUTESHARP_DISABLE_GPU_TIMEOUT switch -->

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about inverting the switch name to ENABLE_GPU_TIMEOUT?

@Sergio0694 Sergio0694 Jun 25, 2023 •

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I was thinking the same as well to avoid the double negation, just figured I'd do that in a separate PR since that's technically unrelated from making the feature switches trimmable. Good point though! 👍

EDIT: fixed by #534 🙂

Comment on lines +6 to +7
<method signature="System.Boolean get_IsDebugOutputEnabled()" body="stub" value="false" feature="COMPUTESHARP_ENABLE_DEBUG_OUTPUT" featurevalue="false"/>
<method signature="System.Boolean get_IsDebugOutputEnabled()" body="stub" value="true" feature="COMPUTESHARP_ENABLE_DEBUG_OUTPUT" featurevalue="true"/>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to substitute the properties only in the case it would result in more code getting trimmed, which here is false.

If debug output is enabled the linker should not bake it into the compiled assembly, but instead the assembly should still support toggling it at runtime through the host configuration.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just so I understand this better, why? Is this like a general guideline? Is it just that if you're enabling additional options it means you're already given up speed so it's not worth it to trim more, or something else? 🤔

@teo-tsirpanis teo-tsirpanis Jun 25, 2023 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way I see it, you want to support removing the debug-related code which means that you want to hardcode disabling debug output. If debug output is not hardcoded to be off, whether to use it will be decided at runtime.

it's not worth it to trim more

What would be trimmed if debug output was hardcoded to be enabled? RuntimeFeature.IsDynamicCode*** can be hardcoded to either true or false, but this can actually trim a compiled or interpreted implementation. What would be the benefit here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

optimization 🚀 Performance improvement to existing APIs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants