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

(#3451) Use availablePackages in GetPackageDependencies #3471

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

josh-cooley
Copy link

Description Of Changes

This updates the dependency handling of packages to use availablePackages when a package from the same source satisfies the dependency. This improves packages that have dependencies with many versions available, and allows less data being requested from servers in the case we have already have available packages from the source.

Without this fix, the installation will be delayed with repeated resolution of the same package dependencies.

Motivation and Context

Installation of packages with many dependent versions available without reducing repeat calls to ResolvePackages

Testing

  1. Download demo-projects.zip
  2. Run GeneratePackages.ps1. This will generate a single package for package-a, package-b, and package-c. It will generate 1000 packages each for package-d and package-e.
  3. Clone and checkout the branch associated with this PR.
  4. Build chocolatey.console.
  5. Run choco upgrade package-a --yes --source <path-to-demo-projects>
  6. See that install/upgrade completes within seconds.

Repeat test with delivered chocolatey 2.3 and see that the install takes much longer.

Operating Systems Testing

  • Windows 10

Change Types Made

  • Bug fix (non-breaking change).
  • Feature / Enhancement (non-breaking change).
  • Breaking change (fix or feature that could cause existing functionality to change).
  • Documentation changes.
  • PowerShell code changes.

Change Checklist

  • Requires a change to the documentation.
  • Documentation has been updated.
  • Tests to cover my changes, have been added.
  • All new and existing tests passed?
  • PowerShell code changes: PowerShell v3 compatibility checked?

Related Issue

Fixes #3451

This updates the dependency handling of packages to use
availablePackages when a package from the same source satisfies the
dependency.  This improves packages that have dependencies with many
versions available, and allows less data being requested from servers
in the case we have already have available packages from the source.

Without this fix, the installation will be delayed with repeated resolution of the same package dependencies.
{
IEnumerable<SourcePackageDependencyInfo> dependencyInfos = Array.Empty<SourcePackageDependencyInfo>();
var dependencyInfoResource = resource.DependencyInfoResource;
Copy link
Member

Choose a reason for hiding this comment

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

DependencyInfoResources() has a not null check, given that you are accessing the dependency info resource directly here, make sure to do check to make sure it is not null.

Copy link
Author

Choose a reason for hiding this comment

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

I've updated it to match the null check in the GetPackagesDependencies overload that takes a PackageIdentity (matches lines 378-382).

Null resources should not be used when resolving packages.
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.

Dependency resolution during install can be slow
2 participants