Skip to content

Fix some blocking in incremental builder #15146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 9 additions & 14 deletions src/Compiler/Service/IncrementalBuild.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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.
Expand Down
7 changes: 5 additions & 2 deletions src/Compiler/Service/IncrementalBuild.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,18 @@ 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.
///
/// 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
Expand Down