-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
Description
When I was looking at #120288 rerpo which is just a simple console app with some Socket server & listener, I noticed a huge chunk of time is spent in NetEventSource::.cctor
(Linux-x64 and I run the app without dotnet-trace
or any env.vars). In that cctor most of the time is spent inside EventSource.GetGuid
that is obtaining custom attributes (presumably over this type)

Here is the GetGuid impl:
runtime/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs
Lines 367 to 379 in a2dc727
public static Guid GetGuid(Type eventSourceType) | |
{ | |
ArgumentNullException.ThrowIfNull(eventSourceType); | |
EventSourceAttribute? attrib = (EventSourceAttribute?)GetCustomAttributeHelper(eventSourceType, typeof(EventSourceAttribute)); | |
string name = eventSourceType.Name; | |
if (attrib != null) | |
{ | |
if (attrib.Guid != null) | |
{ | |
if (Guid.TryParse(attrib.Guid, out Guid g)) | |
return g; | |
} |
Is this something we can avoid "GetCustomAttributes" for and replace with some static map for BCL types?
PS: this is not the root cause of #120288