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

Incorrect PLINQ usage in ToolRestoreCommand #10937

Closed
stephentoub opened this issue Mar 20, 2020 · 0 comments · Fixed by #11338
Closed

Incorrect PLINQ usage in ToolRestoreCommand #10937

stephentoub opened this issue Mar 20, 2020 · 0 comments · Fixed by #11338
Assignees
Milestone

Comments

@stephentoub
Copy link
Member

In this code, the AsParallel() is effectively a nop:

ToolRestoreResult[] toolRestoreResults =
packagesFromManifest
.Select(package => InstallPackages(package, configFile))
.AsParallel().ToArray();

The AsParallel() here is only going to affect the ToArray call, which isn't parallelizable on its own. Presumably the intention was to parallelize the Select.ToArray, in which case the AsParallel needs to be moved to before the Select call:

            ToolRestoreResult[] toolRestoreResults =
                packagesFromManifest
                    .AsParallel()
                    .Select(package => InstallPackages(package, configFile))
                    .ToArray();

If it's not desirable to parallelize the Select call (e.g. if InstallPackages isn't safe to be invoked in parallel or if InstallPackages won't benefit from being invoked in parallel), then the .AsParallel() should just be removed.

@marcpopMSFT marcpopMSFT added the untriaged Request triage from a team member label Apr 6, 2020
@wli3 wli3 removed the untriaged Request triage from a team member label Apr 8, 2020
@wli3 wli3 added this to the 5.0.1xx milestone Apr 8, 2020
@marcpopMSFT marcpopMSFT added the untriaged Request triage from a team member label Apr 16, 2020
@wli3 wli3 removed the untriaged Request triage from a team member label Apr 20, 2020
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 a pull request may close this issue.

3 participants