Create workloads enumerator lazily in dotnet-new host#28677
Merged
JanKrivanek merged 3 commits intodotnet:mainfrom Oct 24, 2022
Merged
Create workloads enumerator lazily in dotnet-new host#28677JanKrivanek merged 3 commits intodotnet:mainfrom
JanKrivanek merged 3 commits intodotnet:mainfrom
Conversation
2 tasks
Member
Author
|
Should we as well right away make sure that logs do not colide (e.g. by adding PID)? https://github.com/dotnet/sdk/blob/main/src/Cli/dotnet/commands/dotnet-workload/install/NetSdkMsiInstallerClient.cs#L949 |
| builtIns.Add((typeof(IWorkloadsInfoProvider), new WorkloadsInfoProvider(new WorkloadInfoHelper()))); | ||
|
|
||
| builtIns.Add((typeof(IWorkloadsInfoProvider), new WorkloadsInfoProvider( | ||
| new Lazy<IWorkloadsRepositoryEnumerator>(() => new WorkloadInfoHelper()))) |
Member
There was a problem hiding this comment.
Should we consider just lazy implementation of IWorkloadsRepositoryEnumerator instead?
just a though
vlada-shubina
approved these changes
Oct 20, 2022
Member
vlada-shubina
left a comment
There was a problem hiding this comment.
The fix looks good from dotnet new standpoint. On the workload side, better logging should be considered (do not fail on logging error, better naming, etc).
2 tasks
JanKrivanek
added a commit
to JanKrivanek/sdk
that referenced
this pull request
Oct 24, 2022
Create workloads enumerator lazily in dotnet-new host
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
dotnet newis creatingWorkloadInfoHelperthat transitively causes creation of 'Microsoft.NET.Workload_.log' log in%temp%folder on each execution (regardles whether workloads constraints are being used or not).This leads to unnecessary I/O operations. Also under specific circumstances
dotnet newcan fail due to log already being created (As log names are being created only with per-second granularity: https://github.com/dotnet/sdk/blob/main/src/Cli/dotnet/commands/dotnet-workload/install/NetSdkMsiInstallerClient.cs#L949) :Sample repro
Solution
Create the workload provider lazily
Additional details
WorkloadInfoHelperis as well used indotnet workloadcommands - so those have the same issue - e.g.:however those command or probably much less likely to be executed in parallel or quick sequence