Skip to content

Commit

Permalink
Remove Async.SwitchToNewThreadCalls (#1144)
Browse files Browse the repository at this point in the history
since dotnet/fsharp#14899 got merged in FCS, it seems we don't hit threadpool exhaustion issues anymore
  • Loading branch information
TheAngryByrd authored Jul 15, 2023
1 parent 2de89b0 commit ee28ad3
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 12 deletions.
12 changes: 0 additions & 12 deletions src/FsAutoComplete.Core/CompilerServiceInterface.fs
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,6 @@ type FSharpCompilerServiceChecker(hasAnalyzers, typecheckCacheSize) =

let allFlags = Array.append [| "--targetprofile:mscorlib" |] fsiAdditionalArguments

do! Async.SwitchToNewThread()

let! (opts, errors) =
checker.GetProjectOptionsFromScript(
UMX.untag file,
Expand All @@ -192,8 +190,6 @@ type FSharpCompilerServiceChecker(hasAnalyzers, typecheckCacheSize) =
let allFlags =
Array.append [| "--targetprofile:netstandard" |] fsiAdditionalArguments

do! Async.SwitchToNewThread()

let! (opts, errors) =
checker.GetProjectOptionsFromScript(
UMX.untag file,
Expand Down Expand Up @@ -269,7 +265,6 @@ type FSharpCompilerServiceChecker(hasAnalyzers, typecheckCacheSize) =
)

let path = UMX.untag filePath
do! Async.SwitchToNewThread()
return! checker.ParseFile(path, source, options)
}

Expand Down Expand Up @@ -299,7 +294,6 @@ type FSharpCompilerServiceChecker(hasAnalyzers, typecheckCacheSize) =
let path = UMX.untag filePath

try
do! Async.SwitchToNewThread()
let! (p, c) = checker.ParseAndCheckFileInProject(path, version, source, options, userOpName = opName)

let parseErrors = p.Diagnostics |> Array.map (fun p -> p.Message)
Expand Down Expand Up @@ -394,8 +388,6 @@ type FSharpCompilerServiceChecker(hasAnalyzers, typecheckCacheSize) =
>> Log.addContextDestructured "file" file
)

do! Async.SwitchToNewThread()

match FSharpCompilerServiceChecker.GetDependingProjects file options with
| None -> return [||]
| Some(opts, []) ->
Expand All @@ -407,7 +399,6 @@ type FSharpCompilerServiceChecker(hasAnalyzers, typecheckCacheSize) =
opts :: dependentProjects
|> List.map (fun (opts) ->
async {
do! Async.SwitchToNewThread()
let opts = clearProjectReferences opts
let! res = checker.ParseAndCheckProject opts
return res.GetUsesOfSymbol symbol
Expand All @@ -424,8 +415,6 @@ type FSharpCompilerServiceChecker(hasAnalyzers, typecheckCacheSize) =
>> Log.addContextDestructured "file" file
)

do! Async.SwitchToNewThread()

return!
checker.FindBackgroundReferencesInFile(
file,
Expand All @@ -444,7 +433,6 @@ type FSharpCompilerServiceChecker(hasAnalyzers, typecheckCacheSize) =
>> Log.addContextDestructured "file" fileName
)

do! Async.SwitchToNewThread()
let! parseResult = checker.ParseFile(UMX.untag fileName, source, options)
return parseResult.GetNavigationItems().Declarations
}
Expand Down
1 change: 1 addition & 0 deletions src/FsAutoComplete/LspServers/AdaptiveFSharpLspServer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ type AdaptiveFSharpLspServer

match parseAndCheck.GetCheckResults.ImplementationFile with
| Some tast ->
// Since analyzers are not async, we need to switch to a new thread to not block threadpool
do! Async.SwitchToNewThread()

let res =
Expand Down

0 comments on commit ee28ad3

Please sign in to comment.