-
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 profiler under a flag #2765
Conversation
@smera, It will cover your contributions to all .NET Foundation-managed open source projects. |
@smera, thanks for signing the contribution license agreement. We will now validate the agreement and then the pull request. |
src/MSBuild/Resources/Strings.resx
Outdated
@@ -1,6 +1,66 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<root> | |||
<!-- |
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.
Can you please revert all the spurious changes that VS did to this file? :)
I edit the resx files from vscode to make sure VS does not dirty them up. #Resolved
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.
sure #Resolved
src/MSBuild/XMake.cs
Outdated
/// <summary> | ||
/// Generates a markdown file on disk with the result of profiling the evaluation | ||
/// </summary> | ||
private static void GenerateProfilerReport(ProfilerLogger profilerLogger) |
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.
Should this logic go in the ProfileLogger? On shutdown or something? #Resolved
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.
I intendedly kept the file saving part outside of the profiler logger because I was seeing the logger more as a collector of data. But I can move the saving logic inside. #Resolved
This is looking really good!! Minor thing, I like that xmake knows how to parse the params to turn on the profiling and create the logger, but I don't think writing the file should be there. That should happen on shutdown like a normal file logger would. So the logger is just something that happens to listen for that data and writes it out in the default format it knows about. @KirillOsenkov seems like we should just add this to the binary logger file. Would be easy to do, and could even have a nice visualization someday? And we're changing the format anyway seems no harm in adding that. So in that case maybe @mmitche any idea what's wrong with our CI? None of the jobs are reporting status apparently. Not sure how to debug that without links to them. #Resolved |
src/Framework/IProjectElement.cs
Outdated
|
||
|
||
/// <summary> | ||
/// The outer xml markup of the xml element associated with this project element/> |
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.
remove />
#Resolved
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.
Will do #Resolved
FYI for the binary logger: and Need to update the version as well since this is (another) breaking change. #Resolved |
They look like they are reporting now. #Resolved |
@AndyGerlicher ci2 was offline for a bit while a server move was happening. #Resolved |
I've filed #2768 to track this. Would indeed be nice to serialize this info to the .binlog if available. @smera if you have cycles would be awesome if you could get to it (perhaps as part of a separate PR). I can come down and explain how binlog serialization works, it's not hard. We can maybe even write it together. #Resolved |
@@ -63,6 +71,9 @@ | |||
<ItemGroup> | |||
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Reference Include="System.Xml" /> |
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.
Please transform this into a nuget dependency instead (project.json file next to this csproj). Mixing nuget and these leads to confusing dependency resolution. #Resolved
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.
Ah, that may explain some warnings I was seeing. Will change, thanks! #Resolved
/// </summary> | ||
[MemberData(nameof(GetProfilerResults))] | ||
[Theory] | ||
public void ProfilerResultRoundTrip(ProfilerResult profilerResult) |
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.
Shouldn't this test go in a new ProjectEvaluationFinishedEventArgs_Tests class instead? #Resolved
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.
Yeap, good catch #Resolved
src/Shared/NodePacketTranslator.cs
Outdated
IDictionary<EvaluationLocation, ProfiledLocation> profiledLocations = new Dictionary<EvaluationLocation, ProfiledLocation>(); | ||
if (translator.Mode == TranslationDirection.WriteToStream) | ||
{ | ||
profiledLocations = profilerResult.ProfiledLocations.ToDictionary(kv => kv.Key, kv => kv.Value); |
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.
This ToDictionary might take some time / memory. How bad would it get if you made ProfilerResult.ProfiledLocations an ImmutableDictionary instead? That one implements IDictionary, and should not need the extra ToDictionary call. #Resolved
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.
I usually prefer IReadOnlyDictionary since the immutability is clearer. Plus this is not in the hot path: it only takes place when the profiler is on, and after an evaluation is done. But if you feel strong about it, I don't mind changing it. #Resolved
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.
let's leave it like this until it becomes a measurable problem :) #Resolved
src/Framework/IProjectElement.cs
Outdated
/// <summary> | ||
/// The outer xml markup of the xml element associated with this project element/> | ||
/// </summary> | ||
string OuterXmlElement { get; } |
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.
Can you rename this to hide the fact that it's XML? Maybe OuterElement
or RawElementRepresentation
, or RawText
#Resolved
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.
Mmhh.. but this was originally being retrieved directly as this.XmlElement.OuterXml. So I thought it was important to communicate the original provenance. I would have exposed XmlElementWithLocation directly (the type of XmlElement), but that needed an extra project reference, and avoiding that was the main purpose of this interface.
But I'm not well versed in the content of a ProjectElement, so I'll follow your advice here. #Resolved
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 ProjectElement wraps over an XmlElement. It is like an MSBuild AST node. I was thinking that if we ever change MSBuild's representation from XML to something else (probably never, but who knows), then having an interface member referencing XML would be cumbersome. #Resolved
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.
Ok, makes sense, will change #Resolved
I'll try to address that as a separate PR In reply to: 348642187 [](ancestors = 348642187) |
/// </summary> | ||
[InlineData(" ")] | ||
[InlineData("a_file_with?invalid_chars")] | ||
[InlineData("C:\\a_path\\with?invalid\\chars")] |
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.
These aren't all invalid on other OSs which is why the tests are failing. #Resolved
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.
Will make this test Windows-specific. Just trying to validate there is a validation going on around invalid chars, so any OS will do
In reply to: 154504123 [](ancestors = 154504123)
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.
In the end I made it slightly more generic to cover other OSs too
In reply to: 154737571 [](ancestors = 154737571,154504123)
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.
Very nice!
@dotnet-bot test this please Odd they all timed out except the full framework build... |
@dotnet-bot test this please |
1 similar comment
@dotnet-bot test this please |
@dotnet-bot test Windows_NT Build for CoreCLR please |
* A bool was attempted to be read twice when reading from the stream. * On read, val.Value was called when null causing an exception. Unrelated to this, if an exception happens during the translate process all the nodes hang.
Fix serialization on Core
Revert nuspec order
Green CI!!! :) |
Adding an evaluation profiler, enabled via a command line flag (/profileevaluation:file).
When turned on, it generates a report after the build finishes. See documentation/evaluation-profiling.md for more details