-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Use EventSource guid ctor for ArrayPoolEventSource #16054
Conversation
|
cc: @vancem |
| } | ||
|
|
||
| // The ArrayPoolEventSource GUID is {0866b2b8-5cef-5db9-2612-0c0ffd814a44} | ||
| private ArrayPoolEventSource() : base(new Guid(0x0866b2b8, 0x5cef, 0x5db9, 0x26, 0x12, 0x0c, 0x0f, 0xfd, 0x81, 0x4a, 0x44), "System.Buffers.ArrayPoolEventSourc") { } |
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 name is missing the “e” at the end.
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.
fixed
|
@vancem Is there a good reason why the lean EventSource constructor that takes Guid is not public so that everybody can use it? It is always unfortunate when we have a internal secret sauce that lets us do things efficiently, but that is not accessible to 3rd party code. |
|
cc @brianrob |
|
@jkotas, from my understanding of this, you'd end up having to specify the GUID twice - once in the custom attribute and once to the constructor. This just makes things a bit more error prone. I suspect that the attribute mechanism predated the constructor which appears to be present to support lean start-up with usage of FrameworkEventSource. It is possible to get rid of the ~16% cost to generate the GUID from the "pre" profile above by specifying the GUID in the attribute, but that doesn't get you away from the reflection to lookup the attribute. We can potentially do something here to make this better for EventSources that incur high costs for very lean scenarios such as this one, but we should think about a holistic way to do this (it could be to make this constructor public). We have another mechanism that gets used in some cases on ProjectN to avoid reflection, and so it would be good to pick one mechanism and make that work for both cases. In terms of this change, I'm happy to take it as long as @vancem doesn't have any concerns. It looks like it fits into the pattern that this constructor was created to address. |
|
The change is fine as it just makes ArrayPoolEventSource like FrameworkEventSource.
The answer is that ideally people using EventSource don't know about GUIDs at all. GUIDS are a ETW thing, not a EventSource thing, and are a source of confusion and complexity (as in this case). Thus ideally we don't expose an EventSource constructor that has a GUID in it at all. The fact that there is a custom attribute that takes a GUID is an legacy issue. It is also a significant potential error, since users will not tend to create the 'right' (they one that WOULD Have been generated from the name) and thus mess up tools that use the name (which is pretty much all tools). It is not a great move (it makes the API trickier). It seems OK for the framework to do such dangerous things, but it is probably best that arbitrary uses don't. So what are better solutions?
None of these options make the API surface 'worse' by adding error prone GUID parameters. MY recommendation is to explore the options in order. Doing just this PR is fine with me. |


Generated the Guid
0866b2b8-5cef-5db9-2612-0c0ffd814a44by adding aConsole.WriteLine(Guid.ToString)to theArrayPoolEventSourceconstructor 😄Resolves https://github.com/dotnet/coreclr/issues/15954