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

Allow references to specify metadata to skip finding dependencies in RAR #2716

Merged
merged 5 commits into from
Nov 30, 2017

Conversation

nguerrera
Copy link
Contributor

@nguerrera nguerrera commented Nov 11, 2017

SDK half: dotnet/sdk#1725

See there for perf numbers

@nguerrera
Copy link
Contributor Author

Copy link
Contributor

@livarcocc livarcocc left a comment

Choose a reason for hiding this comment

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

Test coming?

// Targets that raise references from NuGet packages set FindDependencies=false to skip looking
// for dependencies that they have already resolved and related files that they are responsible
// for deploying.
private static bool ShouldFindDependencies(Reference reference)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be in Reference itself?

I was wondering if a more general name is suited. I want to experiment with this to turn off other RAR behaviour.

Copy link
Contributor Author

@nguerrera nguerrera Nov 14, 2017

Choose a reason for hiding this comment

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

Which other behaviours that are per-reference?

Copy link
Contributor

Choose a reason for hiding this comment

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

When resolving a reference, RAR first looks near all the parents of that reference. If it finds nothing, then it starts asking the resolvers that were actually specified to RAR. I think this could be skipped when the reference is a nuget reference. For example, ProjA -> ProjB ->Nupkg. It's not worth looking for the Nupkg alongside ProjA or ProjB, and skip directly to the actual RAR resolvers. Though even in this case, the FindDependencies name is still valid.

Copy link
Member

Choose a reason for hiding this comment

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

@cdmihai I like that optimization

get
{
string findDependencies = _primarySourceItem?.GetMetadata("FindDependencies");
return string.IsNullOrEmpty(findDependencies) ? true : findDependencies.Equals("true", StringComparison.OrdinalIgnoreCase);
Copy link
Contributor

@cdmihai cdmihai Nov 28, 2017

Choose a reason for hiding this comment

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

Can you please cache this value? It traverses the metadata name, may new up a StringBuilder and other small things. Probably not a big gain though caching it.

@nguerrera nguerrera force-pushed the speed-up-rar branch 2 times, most recently from 0321193 to 90feae2 Compare November 28, 2017 02:25
@nguerrera nguerrera changed the title WIP Allow references to specify metadata to skip finding dependencies in RAR Allow references to specify metadata to skip finding dependencies in RAR Nov 28, 2017
@nguerrera
Copy link
Contributor Author

Code is ready for review, but still working on unit test

{
FindDependenciesAndScatterFiles(reference, newEntries);
SkippedFindingExternallyResolvedDependencies = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

ComputeClosure clears out _references. This flag probably needs to be reset as well right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -2146,6 +2160,8 @@ ReadMachineTypeFromPEHeader readMachineTypeFromPEHeader
assemblyMetadataCache
);

dependencyTable.FindDependenciesOfExternallyResolvedReferences = FindDependenciesOfExternallyResolvedReferences;
Copy link
Contributor

Choose a reason for hiding this comment

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

Quite the large constructor parameter list right? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. Are you OK with this deviation?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, just for the sake of less churn. The large number of arguments seems bad enough and shadows this deviation :)

@nguerrera
Copy link
Contributor Author

@cdmihai Tests are added

@@ -1107,6 +1117,9 @@ string executableExtension
// This is an assembly file, so we'll need to find dependencies later.
DependenciesFound = false;

string externallyResolved = sourceItem.GetMetadata("ExternallyResolved");
ExternallyResolved = string.Equals(externallyResolved, "true", StringComparison.OrdinalIgnoreCase);

Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Can you use:
ExternallyResolved = MetadataConversionUtilities.TryConvertItemMetadataToBool(sourceItem, "ExternallyResolved")

Not used everywhere, but it already is elsewhere in the file so we should try to be consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That looks like it would be an order of magnitude more expensive, but once per reference is probably ok. I'll do it for consistency.

Copy link
Contributor

@AndyGerlicher AndyGerlicher 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!

/// <summary>
/// Externally resolved references do not get their related files identified by RAR. In the common
/// nuget assets case, RAR cannot be the one to identify what to copy because RAR sees only the
/// compile-time assets and not the
Copy link
Contributor

@cdmihai cdmihai Nov 29, 2017

Choose a reason for hiding this comment

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

Sentence ends in cliffhanger :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@cdmihai
Copy link
Contributor

cdmihai commented Nov 30, 2017

Perf looks good.

Build: Time (ms)

Test Overall Significant δ Value
DotnetConsoleProject yes 23.1327 -> 22.8537 (-1.206%)
DotnetWebProject 👌 no 28.3711 -> 28.4794 (0.382%)
DotnetMvcProject 👌 no 30.8593 -> 30.951 (0.297%)
Picasso yes 4520.3862 -> 4483.849 (-0.808%)
SmallP2POldCsproj 🔴 yes 196.7781 -> 198.5418 (0.896%)
SmallP2PNewCsproj 👌 no 174.3653 -> 174.5162 (0.087%)

Build: Memory (bytes)

Test Overall Significant δ Value
DotnetConsoleProject ::ok_hand: no 1166874 -> 1166873 (0%)
DotnetWebProject yes 1312718 -> 1312137 (-0.044%)
DotnetMvcProject ::ok_hand: no 1485719 -> 1485589 (-0.009%)
Picasso 👌 no 193911965 -> 195004016 (0.563%)
SmallP2POldCsproj 🔴 yes 8179031 -> 8196331 (0.212%)
SmallP2PNewCsproj ::ok_hand: no 7268575 -> 7264851 (-0.051%)

@cdmihai cdmihai merged commit 516bf1f into dotnet:master Nov 30, 2017
cdmihai added a commit to dotnet/cli that referenced this pull request Dec 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants