Concurrent installation#1950
Conversation
…into concurrentInstall
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
| _packagesFound.TryUpdate(foundPkgName, newPkgVersions, pkgVersions); | ||
|
|
||
| addedToHash = true; | ||
| } | ||
| } | ||
| else | ||
| { | ||
| _packagesFound.Add(foundPkg.Name, new List<string> { foundPkgVersion }); | ||
| _packagesFound.TryAdd(foundPkg.Name, new List<string> { foundPkgVersion }); |
There was a problem hiding this comment.
Can these to operations of TryAdd and TryUpdate be replaced by AddOrUpdate?
There was a problem hiding this comment.
TryAdd() and TryUpdate() are ConcurrentDictonary methods. I could write an AddOrUpdate() method if that makes things more clear or simple
| if (_knownLatestPkgVersion.ContainsKey(foundPkgName)) | ||
| { | ||
| _knownLatestPkgVersion.TryGetValue(foundPkgName, out PSResourceInfo oldPkgVersion); | ||
| _knownLatestPkgVersion.TryUpdate(foundPkgName, foundPkg, oldPkgVersion); | ||
| addedToHash = true; | ||
| } | ||
| else | ||
| { | ||
| _knownLatestPkgVersion.TryAdd(foundPkg.Name, foundPkg); | ||
| addedToHash = true; |
| // depPkgsFound creates a new instance of depPkgsFound each time FindDependencyPackages() is called. | ||
| // This will eventually return the PSResourceInfo object to the main cmdlet class. | ||
| debugMsgs.Enqueue($"Adding'{key}' to list of dependency packages found"); | ||
| depPkgsFound.TryAdd(key, depPkg); |
There was a problem hiding this comment.
TryAdd adds if not exist. Maybe dont need to check if it contains it before a TryAdd
There was a problem hiding this comment.
The condition is there primarily to know whether to call FindDependencyPackagesHelper(), I could move the TryAdd outside of the condition, but I wouldn't be able to get rid of the condition. I figure if the condition is already being checked, it saves some calls to TryAdd if we already know the depPkg is in depPkgsFound
Co-authored-by: Copilot <copilot@github.com>
…into concurrentInstall
PR Summary
This PR introduces concurrent (parallel) execution for package find/install workflows in PSResourceGet, shifting portions of the implementation to async + thread-safe data structures so multiple package operations can run at the same time.
High level, it’s aimed at improving performance and throughput when users install or query multiple resources in a single invocation by allowing work to be performed concurrently rather than strictly synchronously.
PR Context
Installing (or resolving) many packages sequentially can be slow, especially when many packages are requested, multiple repositories are queried, or network-bound operations dominate runtime.
To support concurrency safely, the PR also updates internal state handling (caches / hashes) to be thread-safe, preventing race conditions and corruption when multiple tasks update shared structures during parallel execution.
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.