-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Trim NetEventSource when EventSource.IsSupported is false #38828
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
Conversation
I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label. |
Tagging subscribers to this area: @dotnet/ncl |
Alternatively, we could just remove |
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.
We are currently migrating from NetEventSources to the new telemetry. It's quite possible that NetEventSources will be eventually completely deleted. Could you please make sure the trimming also works with the new telemetry types? Please, check what has been already done in System.Net.Http #37619 as well the main issue tracking all related work #37428.
As the code is located in a common location it'd be better to update the code to follow pattern which can be automatically removed |
@marek-safar Sorry, it seems I'm missing the point. Could you please clarify which location is a common one? All |
There's NetEventSource.Common.cs, which is built into all of the System.Net.* projects, which then each have their own NetEventSource.SpecificName.cs partial class that provides the actual attribute with the specific name. Any code in common that uses NetEventSource is using the shared definitions. |
Another alternative is to teach the linker to trim this code automatically. I've logged dotnet/linker#1318 for this pattern. If the linker can support it, we shouldn't need to make any change here. |
@marek-safar Please disregard my above comment. I misunderstood you. |
Yep, this PR is fixing the problem for a single assembly but by quick check, it looks like same code is compiled into about 5 other assemblies. They are not Browser critical but still worth considering for other size sensitive configs. |
I'm fine with us changing the |
I can make that change for all the EventSource classes (thanks @alnikola for the pointers on the new ones coming in) if we decide the linker change (dotnet/linker#1318) is not feasible for 5.0. cc @vitek-karas |
eddf3d4
to
6b07aab
Compare
I've updated the PR to remove |
7e296cc
to
a2d2243
Compare
Follow up to dotnet#38129. NetEventSource code was still left in even when EventSource.IsSupported is false, since all the usages of NetEventSource are keying off its own static property: NetEventSource.IsEnabled. Remove NetEventSource.IsEnabled so the linker can trim NetEventSource code when EventSource.IsSupported is false.
… EventSource code when EventSource.IsSupported is false.
a2d2243
to
821f3ad
Compare
src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Ssl.cs
Show resolved
Hide resolved
@@ -145,7 +145,7 @@ private void CheckForShutdown() | |||
|
|||
_ = _connectionClosedTask.ContinueWith(closeTask => | |||
{ | |||
if (closeTask.IsFaulted && NetEventSource.IsEnabled) | |||
if (closeTask.IsFaulted && NetEventSource.Log.IsEnabled()) |
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.
If the clauses here aren't swapped, will the linker end up making this if (closeTask.IsFaulted) { }
or will it be able to eliminate the whole if block, regardless?
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.
The linker will eliminate the conditionally guarded block, any conditions guarding it will be untouched.
src/libraries/System.Net.Sockets/src/System/Net/Sockets/OverlappedAsyncResult.Windows.cs
Show resolved
Hide resolved
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.
I skimmed through the changes. At this point it's "just" changing if (NetEventSource.IsEnabled)
to be if (NetEventSource.Log.IsEnabled)
in the tons of places that occurs, right? Just wanted to make sure I didn't miss anything more critical. Assuming so, LGTM.
Correct. The changes were:
|
Follow up to #38129. NetEventSource code was still left in even when EventSource.IsSupported is false, since all the usages of NetEventSource are keying off its own static property: NetEventSource.IsEnabled.
Remove NetEventSource.IsEnabled so the linker can trim NetEventSource code when EventSource.IsSupported is false.
cc @marek-safar
This trims a little over 8 KB of IL in the CarChecker Blazor app, when EventSource.IsSupported is false.