Skip to content

Commit c70a23a

Browse files
committed
make computing tcInfoExtras in the background cancellable
1 parent 172dc31 commit c70a23a

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

src/Compiler/Service/IncrementalBuild.fs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -316,12 +316,6 @@ type BoundModel private (
316316
})
317317
| _ -> None
318318

319-
let getTcInfo (typeCheck: GraphNode<TypeCheck>) =
320-
async {
321-
let! tcInfo , _, _, _, _ = typeCheck.GetOrComputeValue()
322-
return tcInfo
323-
} |> GraphNode
324-
325319
let getTcInfoExtras (typeCheck: GraphNode<TypeCheck>) =
326320
async {
327321
let! _ , sink, implFile, fileName, _ = typeCheck.GetOrComputeValue()
@@ -370,11 +364,14 @@ type BoundModel private (
370364
return diags
371365
} |> GraphNode
372366

373-
let startComputingFullTypeCheck =
367+
let getTcInfo (typeCheck: GraphNode<TypeCheck>) =
374368
async {
375-
let! _ = tcInfoExtras.GetOrComputeValue()
376-
return! diagnostics.GetOrComputeValue()
377-
}
369+
if not tcInfoExtras.HasValue then
370+
// Also start computing extras, so that typeCheckNode can be GC'd quickly, but don't wait for it.
371+
do! tcInfoExtras.GetOrComputeValue() |> Async.StartChild |> Async.Ignore
372+
let! tcInfo , _, _, _, _ = typeCheck.GetOrComputeValue()
373+
return tcInfo
374+
} |> GraphNode
378375

379376
let tcInfo, tcInfoExtras =
380377
match tcStateOpt with
@@ -385,8 +382,6 @@ type BoundModel private (
385382
// For skipped implementation sources do full type check only when requested.
386383
GraphNode.FromResult tcInfo, tcInfoExtras
387384
| _ ->
388-
// start computing extras, so that typeCheckNode can be GC'd quickly
389-
startComputingFullTypeCheck |> Async.Catch |> Async.Ignore |> Async.Start
390385
getTcInfo typeCheckNode, tcInfoExtras
391386

392387
member val Diagnostics = diagnostics

0 commit comments

Comments
 (0)