Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Conversation

@benaadams
Copy link
Member

@benaadams benaadams commented Jan 27, 2018

Generated the Guid 0866b2b8-5cef-5db9-2612-0c0ffd814a44 by adding a Console.WriteLine(Guid.ToString) to the ArrayPoolEventSource constructor 😄

Resolves https://github.com/dotnet/coreclr/issues/15954

@benaadams
Copy link
Member Author

Post
image

Pre
image

@stephentoub
Copy link
Member

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") { }

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@jkotas jkotas requested a review from vancem January 28, 2018 02:50
@jkotas
Copy link
Member

jkotas commented Jan 28, 2018

@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.

@jkotas
Copy link
Member

jkotas commented Jan 28, 2018

cc @brianrob

@brianrob
Copy link
Member

@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.

@vancem
Copy link

vancem commented Jan 29, 2018

The change is fine as it just makes ArrayPoolEventSource like FrameworkEventSource.

@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.

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?

  1. One option is to do basically just this PR and be done with it. The idea here is that really only the framework EventSources tend to be on critical startup paths, so fixing them is enough.

  2. A second option is to make looking up custom attributes faster. That seems to be the main problem and is general goodness (EventSource can't be the only thing that will touch custom attributes on typical startup paths).

  3. Finally we could add another option to the EventSourceSettings that basically says 'skip looking at custom attributes and generate the GUID yourself. This skips the custom attribute code and goes right to the code to generate it from the name. This is probably not a big part of the overhead (I have not looked at your profiles). At least this option is 'safe' (but it not clear who would use it).

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.

@stephentoub stephentoub merged commit 0f39bc8 into dotnet:master Jan 29, 2018
dotnet-bot pushed a commit to dotnet/corert that referenced this pull request Jan 29, 2018
)

* Use EventSource guid ctor for ArrayPoolEventSource

* missing e

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
dotnet-bot pushed a commit to dotnet/corefx that referenced this pull request Jan 29, 2018
)

* Use EventSource guid ctor for ArrayPoolEventSource

* missing e

Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
jkotas pushed a commit to dotnet/corefx that referenced this pull request Jan 29, 2018
)

* Use EventSource guid ctor for ArrayPoolEventSource

* missing e

Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
jkotas pushed a commit to dotnet/corert that referenced this pull request Jan 29, 2018
)

* Use EventSource guid ctor for ArrayPoolEventSource

* missing e

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
@benaadams benaadams deleted the arraypool-eventsource branch March 11, 2018 20:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants