-
Notifications
You must be signed in to change notification settings - Fork 252
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
Restore speed is slow in 4.0 #4592
Comments
@iskiselev are you able to share this solution? Does this include downloading packages or is this for a noop restore? I have seen some slow downs with csproj PackageReference also, but not to that extent. With xproj there was no evaluation needed, all references including projects were in a static json file. With csproj now all of this has to be evaluated through msbuild which unfortunately takes longer than project.json. Also it is important to point out that to find out if a project has PackageReferences restore has to evaluate it fully. Previously with project.json a simple file scan could determine this. Still 15 minutes seems way too long, so I'm very interested in getting a repro of this. From my own testing on projects such as Roslyn which has 155 projects the restore time is around 25 seconds. |
@emgarten, we probably may share it if NDA will be signed. Would you like me to check it with my managers? |
@iskiselev we can try a few other things first.
|
@iskiselev - are you able to help answer @iskiselev's questions. |
I'll try to provide answers to @emgarten questions today. |
I've done bunch of tests. I've done it on my local machine, so time results a little bit different (it was slower on our build server). I'll provide step-by step description.
For comparison, I checked out same project before conversion to VS 2017, and run twice |
@iskiselev thanks for the detailed feedback! The number of calls made looks roughly correct here. It seems to be spending a lot of time getting the project references. Is there anything unique about your solution with regards to that? Do the projects contain a large number of project references? |
@emgarten, probably you are correct. We started converted our core 12 projects to xproj some time ago, and as there was no support for transitive references before VS 2017 for xproj, most of other (~100) projects has reference to that 12 projects, in addition to normal 3-10 references that they actually need. So, I'd say that most of old csproj with prohect.json contains around 15-25 project references. I'll try to remove that was added only for transitive, and check if it will improve speed, but I won't be able to do it fast - probably in one or two weeks. |
I'll try generating some test solutions with a lot of project to project references to try this out. Keep me posted on what you once you update this also. |
I have cleaned-up most unnecessary transitive p2p references. It works fasted now. It still works 2-3 times slower than NuGet 3.5 on our solution, but probably it is acceptable time. |
@iskiselev thanks for the times, I'm glad to hear that helped! I have some ideas on how perf can be improved for solutions with a lot of p2p references. I'll keep this issue to track that work. |
I was able to repro this using a solution of 127 projects that have 2 target frameworks each and project references to every possible child project. The current targets file takes 15 minutes (similar to the original issue) to collect all restore inputs from the solution. It looks like this can be improve by finding the full set of projects first and then reading each directly instead of relying on MSBuild caching. |
|
Walk project to project references first while creating a minimum number of items to track the full closure of projects. Removing duplicates along the way is important for perf reasons, if too many items are created restore will grind to a halt as they build. Once all projects have been found create specs for the projects directly instead of creating them during the walk. This also helps to keep the number of items down. Performance improvement on a project with 127 projects with a maximum number of project references between them. Before: 900 seconds After: 21 seconds In addition to the perf changes this also adds in the full set of dotnet cli tool references when recursive is set. Getting this information is much easier now that the full set of projects is found up front. Fixes NuGet/Home#4592 Fixes NuGet/Home#4711
Walk project to project references first while creating a minimum number of items to track the full closure of projects. Removing duplicates along the way is important for perf reasons, if too many items are created restore will grind to a halt as they build. Once all projects have been found create specs for the projects directly instead of creating them during the walk. This also helps to keep the number of items down. Performance improvement on a project with 127 projects with a maximum number of project references between them. Before: 900 seconds After: 21 seconds In addition to the perf changes this also adds in the full set of dotnet cli tool references when recursive is set. Getting this information is much easier now that the full set of projects is found up front. Fixes NuGet/Home#4592 Fixes NuGet/Home#4711
The fix for this will be in 4.1.0 (Visual Studio 15.1) My results for this with 127 interlinked projects: |
I still have this problem. 62 projects are restored in 90 seconds. Machine is fast enough (Core I7-6800k@4.2, SSD). |
This is very annoying to wait packages restore 2+ minutes every time after solution opening. I was forced to perform hack to break VS restore functionality: <!-- NuGet Restore Properties -->
<!-- COMMEND THIS
<PropertyPageSchema Include="$(ManagedXamlResourcesDirectory)NuGetRestore.xaml">
<Context>ProjectSubscriptionService</Context>
</PropertyPageSchema>--> And do packages restore manually by command. |
@dmitriyse you mentioned opening a solution, this issue was fixed for command line restore. It sounds like you seeing slow perf with visual studio automatic package restore which hasn't been fixed yet. Take a look at these issues for more details: #4307 Also, you can disable auto restore under the NuGet options in Visual Studio. Disable both the automatic package restore options. Then to restore you can right click on the solution node and select restore. |
@emgarten Thank you for tip with disabling two checkboxes. I solved my problem by removing I found that when I put in the project section: <RuntimeIdentifiers>win7-xxx;ubunty.yyy-yy</RuntimeIdentifiers> packages are restored 3x times longer. I think this is real performance BUG. Probably it should be posted in another issue. Also I think 62 projects ~ 35 seconds is still too much. |
Read solution file, then read 62 csproj files, then read brief info from nuget.spec files from the packages cache (.nuget/) + CPU thinking. 1000 Files read +some calculations, then write 62x500kb files should take ~ not more than 10 seconds on modern hardware. |
For example in my case 62 projects finally references 506 different packages (according to project.assets.file). |
Details about Problem
NuGet product used: msbuild /restore
VS version: VS 2017 RC4
I have solution with 123 project, ~10 of them are new csproj, most of others are old csproj with project.json.
Currently
msbuild /t:restore
takes 15 minutes.Before conversion with xproj and Nuget 3.5 command
nuget restore
for same solution on same environment took only 2 minutes.The text was updated successfully, but these errors were encountered: