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

Allow preinitializing EventSource #101573

Merged
merged 1 commit into from
Apr 26, 2024

Conversation

MichalStrehovsky
Copy link
Member

Contributes to #79204.

We currently don't preinitialize any event sources because they have a finalizer. This is a bit of a problem for places like this:

if (TplEventSource.Log.IsEnabled())
{
TplEventSource.Log.TraceOperationBegin(box.Id, "Async: " + stateMachine.GetType().Name, 0);
}
. We know IsSupported is false so we eliminate the branch, but we still need a cctor check because we access a static (the Log field). The cctor check in a generic method that is instantiated many many many times becomes a death by a thousand papercuts.

Saves 0.7% in size on the stage2 app with EventSource disabled.

Cc @dotnet/ilc-contrib

We currently don't preinitialize any event sources because they have a finalizer. This is a bit of a problem for places like this: https://github.com/dotnet/runtime/blob/5c01ed22b7468a2bee13b498855dcfcc5ae4da50/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncTaskMethodBuilderT.cs#L229-L232. We know `IsSupported` is false so we eliminate the branch, but we still need a cctor check because we access a static. The cctor check in a generic method that is instantiated many many many times becomes a death by a thousand papercuts.

Saves 0.7% in size on the stage2 app with EventSource disabled.
Copy link
Contributor

Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas
See info in area-owners.md if you want to be subscribed.

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

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

Thanks!

@MichalStrehovsky MichalStrehovsky merged commit 0f508f2 into dotnet:main Apr 26, 2024
142 of 147 checks passed
@MichalStrehovsky MichalStrehovsky deleted the evtsrcfin branch April 26, 2024 12:58
matouskozak pushed a commit to matouskozak/runtime that referenced this pull request Apr 30, 2024
We currently don't preinitialize any event sources because they have a finalizer. This is a bit of a problem for places like this: https://github.com/dotnet/runtime/blob/5c01ed22b7468a2bee13b498855dcfcc5ae4da50/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncTaskMethodBuilderT.cs#L229-L232. We know `IsSupported` is false so we eliminate the branch, but we still need a cctor check because we access a static. The cctor check in a generic method that is instantiated many many many times becomes a death by a thousand papercuts.

Saves 0.7% in size on the stage2 app with EventSource disabled.
michaelgsharp pushed a commit to michaelgsharp/runtime that referenced this pull request May 9, 2024
We currently don't preinitialize any event sources because they have a finalizer. This is a bit of a problem for places like this: https://github.com/dotnet/runtime/blob/5c01ed22b7468a2bee13b498855dcfcc5ae4da50/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncTaskMethodBuilderT.cs#L229-L232. We know `IsSupported` is false so we eliminate the branch, but we still need a cctor check because we access a static. The cctor check in a generic method that is instantiated many many many times becomes a death by a thousand papercuts.

Saves 0.7% in size on the stage2 app with EventSource disabled.
@github-actions github-actions bot locked and limited conversation to collaborators May 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants