Repository navigation
perf(#r "paket:"): look for dotnet once and run dotnet nuget locals once per folder, without waiting for an output left open - #4499
Merged
Conversation
A resolution listed the dotnets that exist to run a paket.dll, and again each time it asked dotnet for the NuGet packages folder, where it also picked the dotnet with an SDK each time. List them once, when one is needed, checking that a dotnet exists only when a pick reaches it, and pick the dotnet with an SDK once.
When the local tool isn't restored and no global tool is installed, #r "paket:" ran `dotnet nuget locals` for the folder of the manifest and then for the folder of the script, often the same, and an SDK that hangs made the script wait 30 seconds twice. Ask at most once per folder during a resolution, and in no other folder after a run that timed out, as the same dotnet would hang again: the most recent Paket .NET tool is then only looked for in ~/.nuget/packages. The folder of the script is the DirectoryInfo that findLocalTool walks up from, so that a manifest for that folder gives the same string; the lookup of a --tool-path paket walks up from it too.
…n in #r "paket:" A process that dotnet left running keeps its output open after it exits: #r "paket:" waited 5 more seconds for the end of that output, then took the run for one that timed out, without its folder, and asked no other folder. The folder is now taken from its line as it comes, the output of a dotnet that failed isn't waited for, and only a dotnet that doesn't exit within 30 seconds stops the other folders: a dotnet that exited didn't hang. The command runs in Internals.Logic.runNuGetLocals, with its timeouts as parameters, which the tests run on a stand-in dotnet, a sh script. On .NET Framework, IsPathRooted throws on quotes: the folder of a line is now read in the output handler, where it would end F# Interactive, so such a folder is left out there.
…locals open in #r "paket:" What dotnet left running and keeps its output open stayed running after #r "paket:" took the folder. Once dotnet exited, only Process.Kill(true) on Windows still finds the processes that it started, from its handle, and theirs through the ones that still run: on Linux and macOS it no longer looks for them, and .NET Framework has no Kill(true). There, the end of the output is waited for within 5 seconds after dotnet exits in all, after a failure, a folder or neither, and what keeps it open is then killed.
…out in #r "paket:" A dotnet that printed its global-packages line and then hangs on exit gave TimedOut without its folder: the folder read from that line is now kept, and no other folder is asked for, as after any timeout.
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.
Follows #4498, whose fallback it speeds up.
Problem
When the tool manifest declares paket but its local tool isn't restored, and no global tool is installed,
#r "paket:"randotnet nuget locals global-packages --listtwice withoutNUGET_PACKAGES: in the folder of the manifest, to look for the local tool, and in the folder of the script, for the most recent Paket .NET tool restored. They are often the same folder (build.fsxnext to.config). With an SDK that hangs, the script waited 30 seconds twice before running Paket or failing.The dotnets that exist were also listed each time one was needed: once to run the
paket.dll, and once for eachdotnet nuget locals, which also picked the one with an SDK each time.The command read its whole output, and waited 5 more seconds for its end after dotnet exited. A process that dotnet left running and that keeps the output open made a run that printed its folder count as a timeout: the folder was lost, no other folder was asked, and a local tool restored in the
globalPackagesFolderof anuget.configwas reported as not restored. The output of a dotnet that failed was waited for too, only to be discarded. And a dotnet that printed its folder and then hung on exit lost that folder.Change
During one resolution of the
#r "paket:"lines of a script:paket.dlland the pick of the dotnet with an SDK, which is made once;dotnet nuget localsruns at most once per folder. The folder of the script is theDirectoryInfothatfindLocalToolwalks up from, so that a manifest for that folder gives the same string. When dotnet doesn't exit within 30 seconds, the command doesn't run again for the other folder, which then only has~/.nuget/packages.Internals.Logic.nugetPackagesFolderOncekeeps the answers of a resolution;nugetPackagesFoldertells a timeout (TimedOut) apart from a folder that dotnet doesn't give (Known None).Internals.Logic.runNuGetLocalsruns the command, with its timeouts as parameters:Known None, and the next folder is still asked. Only a dotnet that doesn't exit within 30 seconds givesTimedOut: it is killed with its process tree, and the folder that it printed until then, if any, is kept;Process.Kill(true)still finds the running child processes of an exited process from its handle, the end of the output is waited for within 5 seconds after dotnet exits in all, and what keeps it open is then killed. On Linux and macOS, .NET no longer looks for them once the process exited, and .NET Framework has noKill(true): what dotnet left running stays, as before;Path.IsPathRootedthrows on quotes: a line is now read in the output handler, where the exception would end F# Interactive, so such a folder is left out.Docs:
fsi-integration.mdsays when only~/.nuget/packagesis looked at, that adotnetstopped after 30 seconds keeps the folder it gave, and that the command runs at most once per folder. No release note: the dotnet lookup (#4496),dotnet nuget locals(#4497) and the fallback (#4498) all came after 12.0.0, and their Unreleased lines stay true.Commits:
dotnet nuget localsat most once per folder, withnugetPackagesFolderOnce, its tests and the docs;dotnet nuget localsthat it left open:runNuGetLocals, and its tests on a stand-in dotnet;dotnet nuget localsopen;dotnet nuget localsgave before it timed out.Tests
tests/Paket.Tests/FsiExtension.fstests:nugetPackagesFolderOnce: one run per folder, also when dotnet gives no folder, which doesn't stop the next folder; no run after a timeout; a folder told before a timeout keeps its answer; and the folder of the run that timed out is kept.runNuGetLocals, on a stand-in dotnet, a/bin/shscript that can leave asleeprunning with the output open: the folder of the output, also at once when the output stays open; no folder after a failure, without waiting for an output left open; a timeout that kills the process tree, and keeps the folder printed before it; no timeout for a dotnet that exits with its output left open; the end of the output, which stops the wait; and, withkillsLeftOver, the wait of 5 seconds in all after the exit. These tests are ignored on Windows, and on Linux thekillsLeftOverones can only check the elapsed time, since nothing is killed there.Checked by hand on Linux with the first two commits, SDK 10.0.404 and
dotnet fsi --compilertool:pointing at the built extension, with a manifest that declares a paket that isn't restored, a freshHOMEandDOTNET_CLI_HOME, noNUGET_PACKAGES, andDOTNET_HOST_PATHpointing at adotnetscript that logs its calls, next to thesdk,hostandsharedfolders of the install:.config: onedotnet nuget locals;dotnet nuget localsthat sleeps 45 s: one call, killed after 30 s, and the whole run, ending with the "not restored" error, took 32 s.The wiring has no automated test: the single lookup of the dotnets, the memo shared by the lookup of the local tool and the one of the most recent Paket, and the same string for the folder of the script. That needs an F# Interactive integration test with a manifest that isn't restored, which #4498 lacks too.
Limits
global.jsonof its own that picks a working SDK: the most recent Paket .NET tool is then only looked for in~/.nuget/packages. The same dotnet runs in both folders, and a hang there is unlikely to depend on the folder.#rlines change, and on every run of the script while the local tool isn't restored, as fix(#r "paket:"): fall back when the local tool isn't restored #4498 resolves again after a failure or after a Paket that ran in its place.Kill(true)doesn't find a process started by a process that already exited, as the one of NuGet thatdotnet nugetstarts: the 5 seconds are then waited for nothing, for each folder. A Job Object, or a process group on Linux and macOS, would reach it, with P/Invoke.runNuGetLocalshas no test on Windows, the only OS where it kills after the exit: the stand-in dotnet is a shell script.