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
C#: Avoid explicitly restoring projects in solution files. #14111
base: main
Are you sure you want to change the base?
Conversation
1d86206
to
f41830f
Compare
f41830f
to
e256144
Compare
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.
Added some questions and suggestions. Have you checked how the performance changes simply with using multiple threads for the restores?
| } | ||
|
|
||
| public bool Exec(string execArgs) | ||
| { | ||
| var args = $"exec {execArgs}"; | ||
| return RunCommand(args); | ||
| } | ||
|
|
||
| [GeneratedRegex("Restored\\s+(.+\\.csproj)", RegexOptions.Compiled)] |
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.
Is the output of dotnet restore always English?
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.
Uh, that is an excellent question!
I have tried to set the CLI UI language to german and verified that it prints help in german (so it does respect setting the CLI language). The output of dotnet restore is still in english.
Do you have any other suggestions?
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.
It seems to be translated to German: https://github.com/NuGet/NuGet.Build.Localization/blob/c65073ce9be5c699d7b1cbee913223b77988f6ad/localize/DEU/15/NuGet.Commands.dll.lcl#L1459
DOTNET_CLI_UI_LANGUAGE=de dotnet restore prints the message in German. So maybe we need to set DOTNET_CLI_UI_LANGUAGE=en before running the command. Also, nuget.exe seems to have an option named -ForceEnglishOutput. I don't know if this could be passed to the dotnet CLI to forward it to nuget.
| return true; | ||
| } | ||
|
|
||
| projects = new List<string>(); |
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.
It's probably enough to declare projects with type IEnumerable<string> , and then this new List<string>() could be changed to Array.Empty<string>(), and the above .ToList() could also be removed.
| }); | ||
|
|
||
| private void RestoreProjects(IEnumerable<string> projects) => | ||
| Parallel.ForEach(projects, new ParallelOptions { MaxDegreeOfParallelism = options.Threads }, project => RestoreProject(project)); |
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.
If we restore in parallel, I think the restore logs will overlap each other. Would it make sense to store the stdout of individual processes in a string and only printing it when the process is done?
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.
Ah, yes we can risk that the output is interleaved. I will try to look into this.
No, I have not - I will try that 👍 |
Result for only executing project restore in parallel can be seen below. Execution time when restoring projects in parallel (without using info from restore of solution).Results for OrchardCMS/OrchardCore python3 diff_standalone.py 2123.84s user 421.09s system 289% cpu 14:38.71 total |
In this PR we do the following performance optimisations to the dependency manager.
dotnet restore(after restoring the solution).dotnet restoreon projects are executed in parallel.A couple of implementation details
dotnet restoreverbosity level tonormalwhen restoring solutions to get all the relevant information related to restored projects.DotNet.csfile is starting to contain business logic. In C#: Re-factor Dotnet.cs to enable unit testing. #14142 we re-factorDotNet.csto enable unit testing.The changes have been tested on
OrchardCMS/OrchardCoreas it contains a solution file.The numbers below show that we get the same accuracy for the comparison queries, but the wall clock time drops from approximately 16m to 9m (on my machine).
On main we have:
Results for OrchardCMS/OrchardCore
Query Files.ql:
Result count - both/traced/standalone: 4151/3692/20
Query Declarations.ql:
Result count - both/traced/standalone: 69128/84740/113
Result count in the matching 4151 files - both/traced/standalone: 69128/0/0
Matching 100.0%
Query Dependencies.ql:
Result count - both/traced/standalone: 491/2/229
Query CallTargets.ql:
Result count - both/traced/standalone: 87430/264261/213
Result count in the matching 4151 files - both/traced/standalone: 87430/1523/154
Matching 98.12%
Query TypeHierarchy.ql:
Result count - both/traced/standalone: 6351/4027/23
Result count in the matching 4151 files - both/traced/standalone: 6351/7/5
Matching 99.81%
Query Expressions.ql:
Result count - both/traced/standalone: 311660/1070097/1049
Result count in the matching 4151 files - both/traced/standalone: 311660/6370/870
Matching 97.73%
Query VariableAccesses.ql:
Result count - both/traced/standalone: 86270/193815/39
Result count in the matching 4151 files - both/traced/standalone: 86270/363/0
Matching 99.58%
Query TypeMentions.ql:
Result count - both/traced/standalone: 86709/131893/396
Result count in the matching 4151 files - both/traced/standalone: 86709/1439/319
Matching 98.01%
python3 diff_standalone.py 1510.23s user 299.76s system 188% cpu 15:58.18 total
On the feature branch including the unit test re-factor we have
Results for OrchardCMS/OrchardCore
Query Files.ql:
Result count - both/traced/standalone: 4151/3692/20
Query Declarations.ql:
Result count - both/traced/standalone: 69128/84740/113
Result count in the matching 4151 files - both/traced/standalone: 69128/0/0
Matching 100.0%
Query Dependencies.ql:
Result count - both/traced/standalone: 491/2/229
Query CallTargets.ql:
Result count - both/traced/standalone: 87439/264252/206
Result count in the matching 4151 files - both/traced/standalone: 87439/1514/147
Matching 98.14%
Query TypeHierarchy.ql:
Result count - both/traced/standalone: 6351/4027/23
Result count in the matching 4151 files - both/traced/standalone: 6351/7/5
Matching 99.81%
Query Expressions.ql:
Result count - both/traced/standalone: 311657/1070100/1056
Result count in the matching 4151 files - both/traced/standalone: 311657/6373/877
Matching 97.73%
Query VariableAccesses.ql:
Result count - both/traced/standalone: 86271/193814/39
Result count in the matching 4151 files - both/traced/standalone: 86271/362/0
Matching 99.58%
Query TypeMentions.ql:
Result count - both/traced/standalone: 86709/131893/396
Result count in the matching 4151 files - both/traced/standalone: 86709/1439/319
Matching 98.01%
python3 diff_standalone.py 1107.11s user 143.95s system 234% cpu 8:53.80 total