-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add more events to SDK resolution #7390
Conversation
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.
Overall looks fine to me, but I wonder: should we expose an IsEnabled
that wraps our own functionality there? We use that internally when building the objects to send to ETW is nontrivial, as it will likely be to assemble these single strings (since that's the only way to customize the messages).
For example,
msbuild/src/Build/BackEnd/Components/RequestBuilder/RequestBuilder.cs
Lines 1169 to 1172 in 09bdfae
if (MSBuildEventSource.Log.IsEnabled()) | |
{ | |
MSBuildEventSource.Log.BuildProjectStop(_requestEntry.RequestConfiguration.ProjectFullPath, string.Join(", ", allTargets)); | |
} |
The couple of new events just end up logging the same data (project name, solution path, etc), do you see one that is of particular concern to be expensive? I am not 100% happy with how I'm tracking whether or not a particular resolution is cached. I'm introducing a new |
c4194cc
to
fe6f885
Compare
Constructing the single string will create garbage, but presumably not all that much. It's just concatenation of a bunch of already-existing stuff? |
I'm confused, where is the code constructing a string out of other data? Its just passing properties that come in from the SDK resolution APIs. I'm assuming if tracing is off, the ETW APIs just no-op so we don't have to avoid calling them if tracing is off? Or am completely wrong about all that? 😕 |
That's true, the ETW APIs are very lightweight if the events are disabled. However, the .NET runtime doesn't know about that, so it has to fully realize arguments The case I'm trying to avoid is: // In SDK resolver
WriteEvent(s1 + s2 + s3);
// or
WriteEvent($"Some formatting string with {holes} that {get} {filled}");
// or worst case
WriteEvent(ExpensiveMethodThatDoesABunchOfWork()); |
Yeah okay I totally understand, we don't want to do string formatting of any kind that will allocate just to call a method that no-ops. I don't think any of the code paths I'm adding here are doing that, they all take existing objects and pass them directly to ETW APIs. |
Ah, I've been unclear: none of the APIs in this PR are bad on this front. My question is: does this encourage/require bad behavior in the resolvers because of the API shape we're exposing? |
Okay I finally understand what you mean. That's a valid concern, callers could end up building expensive strings that aren't actually used. My original implementation tried to accept The ETW API is not designed to allow external code to contribute to your events! So I'm removing all of the code around allowing SDK resolvers to contribute their own events. Instead, I'll just add my own |
fe6f885
to
29e5146
Compare
@@ -34,6 +34,7 @@ EventSource is primarily used to profile code. For MSBuild specifically, a major | |||
| Save | Saves a project to the file system if dirty, creating directories as necessary. | | |||
| SdkResolverResolveSdk | A single SDK resolver is called. | | |||
| SdkResolverServiceInitialize | Initializes SDK resolvers. | | |||
| SdkResolverEvent | An SDK resolver logs an event. | |
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.
Is this still a thing?
Fixes #7136
Context
Second attempt at adding more ETW events for SDK resolution.
Changes Made
CachingSdkResolverService
MSBuildEventSource
reminding us that you must rev the version of an event when changing the method signatureTesting
Ran locally built
msbuild.exe
withperfview
and verified the events show up properly.Notes