PaketRestoreLockFileHash = PaketRestoreCachedHash slow
See original GitHub issueDescription
Using dotnet restore -v diag
it spends a lot of time on PaketRestore
:
Target Performance Summary:
0 ms ValidateProjects 1 calls
0 ms _GenerateRestoreGraphProjectEntry 11 calls
0 ms ValidateToolsVersions 1 calls
1 ms CheckForImplicitPackageReferenceOverridesBeforeRestore 22 calls
1 ms _GenerateProjectRestoreGraph 11 calls
1 ms _GetRestoreProjectStyle 33 calls
2 ms _GetRestoreTargetFrameworksAsItems 24 calls
3 ms _GetRestoreSettingsOverrides 11 calls
4 ms _IsProjectRestoreSupported 11 calls
5 ms _GenerateRestoreProjectPathItemsPerFramework 17 calls
7 ms _GetRestoreSettingsPerFramework 17 calls
10 ms _GenerateRestoreSpecs 11 calls
10 ms _GetProjectJsonPath 33 calls
13 ms _GenerateRestoreProjectSpec 11 calls
18 ms _GenerateDotnetCliToolReferenceSpecs 11 calls
21 ms GetAllRuntimeIdentifiers 28 calls
22 ms ValidateSolutionConfiguration 1 calls
23 ms _LoadRestoreGraphEntryPoints 1 calls
24 ms _GetRestoreTargetFrameworksOutput 24 calls
57 ms _GenerateProjectRestoreGraphPerFramework 17 calls
65 ms _GetRestoreSettings 11 calls
534 ms _FilterRestoreGraphProjectInputItems 1 calls
693 ms Restore 1 calls
883 ms _GenerateRestoreProjectPathItems 24 calls
998 ms _GenerateRestoreProjectPathWalk 24 calls
1442 ms _GetAllRestoreProjectPathItems 1 calls
28582 ms _GenerateRestoreDependencies 11 calls
45459 ms PaketRestore 28 calls
45833 ms _GenerateRestoreGraph 1 calls
I narrowed Paket.Restore.targets
down to these lines with a large enough lock file (case about 2500 lines) the ReadAllText
functions is extremely slow.
<PropertyGroup Condition="Exists('$(PaketRestoreCacheFile)') ">
<PaketRestoreCachedHash>$([System.IO.File]::ReadAllText('$(PaketRestoreCacheFile)'))</PaketRestoreCachedHash>
<PaketRestoreLockFileHash>$([System.IO.File]::ReadAllText('$(PaketLockFilePath)'))</PaketRestoreLockFileHash>
<PaketRestoreRequired>true</PaketRestoreRequired>
<PaketRestoreRequired Condition=" '$(PaketRestoreLockFileHash)' == '$(PaketRestoreCachedHash)' ">false</PaketRestoreRequired>
<PaketRestoreRequired Condition=" '$(PaketRestoreLockFileHash)' == '' ">true</PaketRestoreRequired>
</PropertyGroup>
Repro steps
Generate a paket.lock
file of about 2500 lines long.
Expected behavior
Actual behavior
Known workarounds
This is not a permanent solution but for comparison if i use the built in shasum
function on osx/linux:
<Exec Command="shasum $(PaketRestoreCacheFile) | awk '{ print $1 }' " ConsoleToMSBuild='true'>
<Output TaskParameter="ConsoleOutput" PropertyName="PaketRestoreCachedHash" />
</Exec>
<Exec Command="shasum $(PaketLockFilePath) | awk '{ print $1 }'" ConsoleToMSBuild='true'>
<Output TaskParameter="ConsoleOutput" PropertyName="PaketRestoreLockFileHash" />
</Exec>
<PropertyGroup Condition="Exists('$(PaketRestoreCacheFile)') ">
<PaketRestoreRequired>true</PaketRestoreRequired>
<PaketRestoreRequired Condition=" '$(PaketRestoreLockFileHash)' == '$(PaketRestoreCachedHash)' ">false</PaketRestoreRequired>
<PaketRestoreRequired Condition=" '$(PaketRestoreLockFileHash)' == '' ">true</PaketRestoreRequired>
</PropertyGroup>
Target Performance Summary:
0 ms ValidateProjects 1 calls
0 ms ValidateToolsVersions 1 calls
0 ms _GenerateRestoreGraphProjectEntry 11 calls
1 ms CheckForImplicitPackageReferenceOverridesBeforeRestore 22 calls
1 ms _GetRestoreProjectStyle 33 calls
2 ms _GenerateProjectRestoreGraph 11 calls
3 ms _GetRestoreSettingsOverrides 11 calls
3 ms _IsProjectRestoreSupported 11 calls
4 ms _GetRestoreTargetFrameworksAsItems 24 calls
6 ms _GenerateRestoreProjectPathItemsPerFramework 17 calls
6 ms _GetRestoreSettingsPerFramework 17 calls
9 ms _GenerateRestoreSpecs 11 calls
10 ms _GetProjectJsonPath 33 calls
18 ms _GenerateRestoreProjectSpec 11 calls
22 ms _GenerateDotnetCliToolReferenceSpecs 11 calls
22 ms _GetRestoreTargetFrameworksOutput 24 calls
22 ms ValidateSolutionConfiguration 1 calls
24 ms _LoadRestoreGraphEntryPoints 1 calls
29 ms GetAllRuntimeIdentifiers 28 calls
66 ms _GenerateProjectRestoreGraphPerFramework 17 calls
81 ms _GetRestoreSettings 11 calls
545 ms _FilterRestoreGraphProjectInputItems 1 calls
653 ms Restore 1 calls
892 ms _GenerateRestoreProjectPathItems 24 calls
1009 ms _GenerateRestoreProjectPathWalk 24 calls
1455 ms _GetAllRestoreProjectPathItems 1 calls
2781 ms _GenerateRestoreDependencies 11 calls
3697 ms PaketRestore 28 calls
4120 ms _GenerateRestoreGraph 1 calls
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
paket restore
paket restore fails with an error if the paket.lock file does not exist. No packages are downloaded in that case. Please see paket...
Read more >The paket.lock file
The paket.lock file records the concrete dependency resolution of all direct and transitive dependencies of your project: ...
Read more >Paket.Restore.targets
if no hash has been done yet fall back to just reading in the files and comparing them -->. 78. <PaketRestoreCachedHash Condition=" ...
Read more >Enable repeatable package restores using a lock file
During restore , it verifies that the content hashes match between the lock file and actual restored packages. In case of discrepancy, NuGet ......
Read more >g7
Amchit beach, Battlefield 1 change resolution file, Bridging exercise untuk ... Cara reset samsung j prime, Assistant brand manager jakarta february 2018, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have no idea why a simple read on a file with 3k lines would take as long as this. Basically all we want is a way to check if something changed.
This is the only practical cross-platform way I could come up with. As nice as such unix tricks are you cannot really assume that
shasum
awk
or other tricks are available.Please feel free to send a solution as I couldn’t find one, sorry. I give up on this one (I never noticed such slowdowns so I guess you have a slow hard drive? Or it is a osx/linux problem?)
Bleh. Just noticed you’ll get output like
Why are we using msbuild again? :trollface: