-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Create workloads enumerator lazily in dotnet-new host #28677
Conversation
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()))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we consider just lazy implementation of IWorkloadsRepositoryEnumerator
instead?
just a though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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).
Create workloads enumerator lazily in dotnet-new host
Problem
dotnet new
is creatingWorkloadInfoHelper
that 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 new
can 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
WorkloadInfoHelper
is as well used indotnet workload
commands - so those have the same issue - e.g.:however those command or probably much less likely to be executed in parallel or quick sequence