Fix some blocking in incremental builder (#15146)

This commit is contained in:
Jakub Majocha 2023-04-27 10:34:18 +02:00 коммит произвёл GitHub
Родитель ab42a322bc
Коммит 9627d3373e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 14 добавлений и 16 удалений

Просмотреть файл

@ -914,7 +914,7 @@ module IncrementalBuilderStateHelpers =
return! prevBoundModel.Next(syntaxTree)
})
let rec createFinalizeBoundModelGraphNode (initialState: IncrementalBuilderInitialState) (boundModels: GraphNode<BoundModel> seq) =
let createFinalizeBoundModelGraphNode (initialState: IncrementalBuilderInitialState) (boundModels: GraphNode<BoundModel> seq) =
GraphNode(node {
use _ = Activity.start "GetCheckResultsAndImplementationsForProject" [|Activity.Tags.project, initialState.outfile|]
let! result =
@ -928,7 +928,7 @@ module IncrementalBuilderStateHelpers =
return result, DateTime.UtcNow
})
and computeStampedFileNames (initialState: IncrementalBuilderInitialState) (state: IncrementalBuilderState) (cache: TimeStampCache) =
let computeStampedFileNames (initialState: IncrementalBuilderInitialState) (state: IncrementalBuilderState) (cache: TimeStampCache) =
let slots =
if initialState.useChangeNotifications then
state.slots
@ -967,7 +967,7 @@ module IncrementalBuilderStateHelpers =
else
state
and computeStampedReferencedAssemblies (initialState: IncrementalBuilderInitialState) state canTriggerInvalidation (cache: TimeStampCache) =
let computeStampedReferencedAssemblies (initialState: IncrementalBuilderInitialState) state canTriggerInvalidation (cache: TimeStampCache) =
let stampedReferencedAssemblies = state.stampedReferencedAssemblies.ToBuilder()
let mutable referencesUpdated = false
@ -1132,11 +1132,6 @@ type IncrementalBuilder(initialState: IncrementalBuilderInitialState, state: Inc
do! setCurrentState currentState cache ct
}
let checkFileTimeStampsSynchronously cache =
checkFileTimeStamps cache
|> Async.AwaitNodeCode
|> Async.RunSynchronously
do IncrementalBuilderEventTesting.MRU.Add(IncrementalBuilderEventTesting.IBECreated)
member _.TcConfig = tcConfig
@ -1192,10 +1187,10 @@ type IncrementalBuilder(initialState: IncrementalBuilderInitialState, state: Inc
member builder.TryGetCheckResultsBeforeFileInProject fileName =
let cache = TimeStampCache defaultTimeStamp
checkFileTimeStampsSynchronously cache
let tmpState = computeStampedFileNames initialState currentState cache
let slotOfFile = builder.GetSlotOfFileName fileName
match tryGetBeforeSlot currentState slotOfFile with
match tryGetBeforeSlot tmpState slotOfFile with
| Some(boundModel, timestamp) ->
let projectTimeStamp = builder.GetLogicalTimeStampForFileInProject(fileName)
Some (PartialCheckResults (boundModel, timestamp, projectTimeStamp))
@ -1277,12 +1272,12 @@ type IncrementalBuilder(initialState: IncrementalBuilderInitialState, state: Inc
member _.GetLogicalTimeStampForFileInProject(slotOfFile: int) =
let cache = TimeStampCache defaultTimeStamp
checkFileTimeStampsSynchronously cache
computeProjectTimeStamp currentState slotOfFile
let tempState = computeStampedFileNames initialState currentState cache
computeProjectTimeStamp tempState slotOfFile
member _.GetLogicalTimeStampForProject(cache) =
checkFileTimeStampsSynchronously cache
computeProjectTimeStamp currentState -1
let tempState = computeStampedFileNames initialState currentState cache
computeProjectTimeStamp tempState -1
member _.TryGetSlotOfFileName(fileName: string) =
// Get the slot of the given file and force it to build.

Просмотреть файл

@ -185,6 +185,8 @@ type internal IncrementalBuilder =
/// This is safe for use from non-compiler threads but the objects returned must in many cases be accessed only from the compiler thread.
member GetCheckResultsForFileInProjectEvenIfStale: fileName: string -> PartialCheckResults option
// TODO: Looks like the following doc does not match the actual method or it's signature.
/// Get the preceding typecheck state of a slot, but only if it is up-to-date w.r.t.
/// the timestamps on files and referenced DLLs prior to this one. Return None if the result is not available.
/// This is a relatively quick operation.
@ -192,8 +194,9 @@ type internal IncrementalBuilder =
/// This is safe for use from non-compiler threads
member AreCheckResultsBeforeFileInProjectReady: fileName: string -> bool
/// Get the preceding typecheck state of a slot, WITH checking if it is up-to-date w.r.t. However, files will not be parsed or checked.
/// the timestamps on files and referenced DLLs prior to this one. Return None if the result is not available or if it is not up-to-date.
/// Get the preceding typecheck state of a slot, WITH checking if it is up-to-date w.r.t. the timestamps of files and referenced DLLs prior to this one.
/// However, files will not be parsed or checked.
/// Return None if the result is not available or if it is not up-to-date.
///
/// This is safe for use from non-compiler threads but the objects returned must in many cases be accessed only from the compiler thread.
member TryGetCheckResultsBeforeFileInProject: fileName: string -> PartialCheckResults option