Mark UseWindowsThreadPool as feature switch #40372
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 theAppContext
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