Skip to content
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

Log RAR "size" in ETW #6410

Merged
merged 6 commits into from
Jun 4, 2021
Merged

Conversation

rainersigwald
Copy link
Member

Context

I'm poking around the question "why do builds using the .NET SDK take longer than older non-SDK builds?" and RAR time is one major factor. It'd be nice to have a complexity estimate in the ETW events: is this RAR instance resolving 3 files, or 300?

Changes Made

Add lightweight information about the size/complexity of a RAR
invocation by logging counts of the most interesting input/output lists.

Testing

Collected updated traces manually and confirmed data present.

⚠ Note this is currently targeting 16.11. Open to discussion on pushing it to main/17.0 instead.

Add lightweight information about the size/complexity of a RAR
invocation by logging counts of the most interesting input/output lists.
Copy link
Member

@Forgind Forgind left a comment

Choose a reason for hiding this comment

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

Looks good. Didn't I have something similar to this for ComputeClosure? I don't remember how that one ended.

Since this is perf oriented, I doubt we'd use it much pre-dev17, so I think it may as well go there. Open to counterarguments.

It looks like it's pointing to main, though? I thought main was already 17.0?

@rainersigwald rainersigwald changed the base branch from main to vs16.11 May 4, 2021 16:56
@rainersigwald
Copy link
Member Author

It looks like it's pointing to main, though? I thought main was already 17.0?

😠 GitHub reset the branch somehow before I hit submit I think. Retargeted to where I intended to have it all along.

Copy link
Contributor

@rokonec rokonec left a comment

Choose a reason for hiding this comment

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

Apart from null propagation hint at Stop events it make me happy. This will capture very valuable perf data.

@@ -2596,7 +2596,7 @@ out _copyLocalFiles
}
}

MSBuildEventSource.Log.RarOverallStop();
MSBuildEventSource.Log.RarOverallStop(_resolvedFiles.Length, _resolvedDependencyFiles.Length, _copyLocalFiles.Length);
Copy link
Contributor

Choose a reason for hiding this comment

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

Please consider to use null check/propagation, for example _copyLocalFiles?.Length at both Stop events callings. It is not guaranteed to be not null - especially in catch scenarios.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, great idea! That has bitten us before . . .

@@ -2579,7 +2579,7 @@ out _copyLocalFiles
}
}
}
MSBuildEventSource.Log.RarOverallStop();
MSBuildEventSource.Log.RarOverallStop(_assemblyNames.Length, _assemblyFiles.Length, _resolvedFiles?.Length ?? 0, _resolvedDependencyFiles?.Length ?? 0, _copyLocalFiles?.Length ?? 0);
Copy link
Member

Choose a reason for hiding this comment

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

(not crazy familiar with RAR)
_assemblyNames is guaranteed not to be null here? There's a null check at the beginning of the method

Copy link
Member Author

Choose a reason for hiding this comment

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

I believe it is because it's initialized to an Array.Empty, but the null check is fast and easy so I'm just going to do it here too.

@@ -2109,7 +2109,7 @@ ReadMachineTypeFromPEHeader readMachineTypeFromPEHeader
)
{
bool success = true;
MSBuildEventSource.Log.RarOverallStart();
MSBuildEventSource.Log.RarOverallStart(_assemblyNames?.Length ?? 0, _assemblyFiles?.Length ?? 0, _findDependencies);
Copy link
Member

Choose a reason for hiding this comment

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

Maybe do this with ?? -1 to indicate null?

Also, things like _assemblyNames and _assemblyFiles shouldn't change over the course of an execution, right? So only log them at Stop? Can probably move _findDependencies there, too, so everything is together.

Copy link
Member

Choose a reason for hiding this comment

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

I'm also wondering if we care about the difference between _assemblyNames and _assemblyFiles. Only one should be defined, right? And if they have the same meaning (resolve this many things), maybe have like _assemblyNames?.Length ?? _assemblyFiles?.Length ?? -1

Copy link
Member

Choose a reason for hiding this comment

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

Did you decide yea or nay on these two?

Copy link
Member Author

Choose a reason for hiding this comment

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

I had not!

Looks pretty good now

image

I'm also wondering if we care about the difference between _assemblyNames and _assemblyFiles. Only one should be defined, right? And if they have the same meaning (resolve this many things), maybe have like _assemblyNames?.Length ?? _assemblyFiles?.Length ?? -1

They're not the same thing and many/most builds pass into both.

@Forgind Forgind added the merge-when-branch-open PRs that are approved, except that there is a problem that means we are not merging stuff right now. label Jun 2, 2021
@Forgind Forgind merged commit f1675f8 into dotnet:vs16.11 Jun 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge-when-branch-open PRs that are approved, except that there is a problem that means we are not merging stuff right now. performance Performance-Scenario-Build This issue affects build performance. Task: Resolve Assembly References (RAR)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants