Skip to content
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

Mark UseWindowsThreadPool as feature switch #40372

Merged
merged 1 commit into from Apr 24, 2024

Conversation

MichalStrehovsky
Copy link
Member

Saves 30 kB on a PublishTrimmed Hello World app that uses Windows thread pool (and ~10 kB if using the portable thread pool).

This is a feature switch that trimming can optimize, but we weren't optimizing it because the RuntimeHostConfigurationOption wasn't manifested as a feature switch (this was just setting the AppContext value).

I would have noticed this on native AOT because I monitor hello world size pretty closely, but it looks like native AOT special cased it to treat it as a feature switch here: https://github.com/dotnet/runtime/blob/7bb7e74d6b1f22e69654f038b06d7688a6ac45de/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets#L293. The optimization was only missing for PublishTrimmed as a result. The line in native AOT targets should be deleted once we ingest the new SDK with this fix.

Noticed this because this resulted in some conflicts within the https://github.com/dotnet/runtime/blob/7bb7e74d6b1f22e69654f038b06d7688a6ac45de/src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/UseWindowsThreadPoolFalse.cs test as I'm in the process of bringing those up with native AOT.

Cc @eduardo-vp @kouvel @eerhardt @dotnet/illink-contrib

Saves 30 kB on a PublishTrimmed Hello World app that uses Windows thread pool (and ~10 kB if using the portable thread pool).

This is a feature switch that trimming can optimize, but we weren't optimizing it because the `RuntimeHostConfigurationOption` wasn't manifested as a feature switch (this was just setting the `AppContext` value).

I would have noticed this on native AOT because I monitor hello world size pretty closely, but it looks like native AOT special cased it to treat it as a feature switch here: https://github.com/dotnet/runtime/blob/7bb7e74d6b1f22e69654f038b06d7688a6ac45de/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets#L293. The optimization was only missing for PublishTrimmed as a result. The line in native AOT targets should be deleted once we ingest the new SDK with this fix.

Noticed this because this resulted in some conflicts within the https://github.com/dotnet/runtime/blob/7bb7e74d6b1f22e69654f038b06d7688a6ac45de/src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/UseWindowsThreadPoolFalse.cs test as I'm in the process of bringing those up with native AOT.
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-ILLink untriaged Request triage from a team member labels Apr 23, 2024
Copy link
Member

@eerhardt eerhardt left a comment

Choose a reason for hiding this comment

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

LGTM. Nice catch.

@MichalStrehovsky MichalStrehovsky merged commit e3c6213 into main Apr 24, 2024
16 checks passed
@MichalStrehovsky MichalStrehovsky deleted the MichalStrehovsky-patch-1 branch April 24, 2024 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-ILLink untriaged Request triage from a team member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants