Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
76ee7af
Add unit tests to illustrate the problem.
nojaf Jun 7, 2023
2e3d9b6
fix block on synchronous state updates
majocha Apr 26, 2023
cd318ff
revert it fully
majocha Apr 26, 2023
9449485
reduce code complexity a bit
majocha Apr 26, 2023
e6b6214
wip
majocha Apr 26, 2023
e3ad0fd
experiment with removing semaphore
majocha Apr 27, 2023
2754a9e
wip
majocha Apr 27, 2023
2961583
simpler computeStampedReferencedAssemblies
majocha Apr 28, 2023
ead227d
wip versioning boundmodels
majocha Apr 28, 2023
d1fee87
wip
majocha Apr 28, 2023
a9aead8
wip
majocha Apr 30, 2023
26d7232
restore
majocha Apr 30, 2023
e781adc
wip
majocha May 1, 2023
15049c4
just PartialCheckResults
majocha May 2, 2023
9cc1fe4
green
majocha May 2, 2023
f828a12
wip
majocha May 2, 2023
5801b6d
fix
majocha May 3, 2023
af63f1a
wip
majocha May 3, 2023
d649437
priorTimeStamp
majocha May 3, 2023
c0d2da6
simplify
majocha May 3, 2023
af0b021
more stamps
majocha May 3, 2023
f05dd51
Merge branch 'missing-diagnostic' into ib-reduce-complexity
majocha Jun 7, 2023
545912d
diag fix
majocha Jun 8, 2023
bde9882
format
majocha Jun 8, 2023
bcad3e2
Add unit tests to illustrate the problem.
nojaf Jun 7, 2023
5cb8f37
fix block on synchronous state updates
majocha Apr 26, 2023
f4d0518
revert it fully
majocha Apr 26, 2023
2a3f5e8
reduce code complexity a bit
majocha Apr 26, 2023
e499417
wip
majocha Apr 26, 2023
0bbed02
experiment with removing semaphore
majocha Apr 27, 2023
2b0a803
wip
majocha Apr 27, 2023
b046c14
simpler computeStampedReferencedAssemblies
majocha Apr 28, 2023
86b2b3e
wip versioning boundmodels
majocha Apr 28, 2023
2dfadcd
wip
majocha Apr 28, 2023
82ca562
wip
majocha Apr 30, 2023
0b7360c
restore
majocha Apr 30, 2023
1a7ea76
wip
majocha May 1, 2023
1b6a540
just PartialCheckResults
majocha May 2, 2023
0697f07
green
majocha May 2, 2023
95d2f5c
wip
majocha May 2, 2023
8170794
fix
majocha May 3, 2023
2f0b1d6
wip
majocha May 3, 2023
ba335e8
priorTimeStamp
majocha May 3, 2023
6b64066
simplify
majocha May 3, 2023
8784539
more stamps
majocha May 3, 2023
225d514
diag fix
majocha Jun 8, 2023
cc14659
format
majocha Jun 8, 2023
1faf238
Merge branch 'ib-reduce-complexity' of https://github.com/majocha/fsh…
majocha Jun 8, 2023
15be259
stamp final check result
majocha Jun 8, 2023
4779a86
this is silly
majocha Jun 8, 2023
ac7c2c3
Merge branch 'main' into ib-reduce-complexity
majocha Jun 8, 2023
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
Prev Previous commit
Next Next commit
experiment with removing semaphore
  • Loading branch information
majocha committed Jun 8, 2023
commit 0bbed02b8c7506d0c1d1e69e0ce158366a037cde
60 changes: 20 additions & 40 deletions src/Compiler/Service/IncrementalBuild.fs
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ type BoundModel private (
itemKeyStore = itemKeyStore
semanticClassificationKeyStore = semanticClassification
}
} |> GraphNode
}

let defaultTypeCheck =
node {
Expand All @@ -451,7 +451,7 @@ type BoundModel private (

let typeCheckNode = syntaxTreeOpt |> Option.map getTypeCheck |> Option.defaultValue defaultTypeCheck |> GraphNode

let tcInfoExtras = getTcInfoExtras typeCheckNode
let tcInfoExtras = GraphNode (getTcInfoExtras typeCheckNode)

let tcInfo =
node {
Expand Down Expand Up @@ -882,12 +882,10 @@ type IncrementalBuilderInitialState =

// Stamp represent the real stamp of the file.
// Notified indicates that there is pending file change.
// LogicalStamp represent the stamp of the file that is used to calculate the project's logical timestamp.
type Slot =
{
HasSignature: bool
Stamp: DateTime
LogicalStamp: DateTime
SyntaxTree: SyntaxTree
Notified: bool
BoundModel: BoundModel
Expand All @@ -904,7 +902,6 @@ type IncrementalBuilderState =
finalizedBoundModel: GraphNode<(ILAssemblyRef * ProjectAssemblyDataResult * CheckedImplFile list option * BoundModel) * DateTime>
}
member this.stampedFileNames = this.slots |> List.map (fun s -> s.Stamp)
member this.logicalStampedFileNames = this.slots |> List.map (fun s -> s.LogicalStamp)
member this.boundModels = this.slots |> List.map (fun s -> s.BoundModel)

[<AutoOpen>]
Expand Down Expand Up @@ -944,7 +941,6 @@ module IncrementalBuilderStateHelpers =
let update newStatus =
let boundModel = nextBoundModel prevBoundModel slot.SyntaxTree
{ slot with
LogicalStamp = slot.Stamp
Notified = false
BoundModel = boundModel },
(newStatus, boundModel)
Expand Down Expand Up @@ -1034,7 +1030,6 @@ type IncrementalBuilderState with
{
HasSignature = hasSignature
Stamp = DateTime.MinValue
LogicalStamp = DateTime.MinValue
Notified = false
SyntaxTree = syntaxTree
BoundModel = model
Expand Down Expand Up @@ -1104,28 +1099,15 @@ type IncrementalBuilder(initialState: IncrementalBuilderInitialState, state: Inc
MaxTimeStampInDependencies state.stampedReferencedAssemblies -1
else
let t1 = MaxTimeStampInDependencies state.stampedReferencedAssemblies -1
let t2 = MaxTimeStampInDependencies state.logicalStampedFileNames fileSlot
let t2 = MaxTimeStampInDependencies state.stampedFileNames fileSlot
max t1 t2

let semaphore = new SemaphoreSlim(1,1)

let mutable currentState = state

let setCurrentState state cache (ct: CancellationToken) =
node {
do! semaphore.WaitAsync(ct) |> NodeCode.AwaitTask
try
ct.ThrowIfCancellationRequested()
currentState <- computeStampedFileNames initialState state cache
finally
semaphore.Release() |> ignore
}
let setCurrentState state cache =
currentState <- computeStampedFileNames initialState state cache

let checkFileTimeStamps (cache: TimeStampCache) =
node {
let! ct = NodeCode.CancellationToken
do! setCurrentState currentState cache ct
}
let checkFileTimeStamps cache = setCurrentState currentState cache

do IncrementalBuilderEventTesting.MRU.Add(IncrementalBuilderEventTesting.IBECreated)

Expand Down Expand Up @@ -1155,7 +1137,7 @@ type IncrementalBuilder(initialState: IncrementalBuilderInitialState, state: Inc
member _.PopulatePartialCheckingResults () =
node {
let cache = TimeStampCache defaultTimeStamp // One per step
do! checkFileTimeStamps cache
checkFileTimeStamps cache
let _ = currentState.finalizedBoundModel
projectChecked.Trigger()
}
Expand All @@ -1174,17 +1156,16 @@ type IncrementalBuilder(initialState: IncrementalBuilderInitialState, state: Inc

member builder.TryGetCheckResultsBeforeFileInProject fileName =
let cache = TimeStampCache defaultTimeStamp
let tmpState = computeStampedFileNames initialState currentState cache

checkFileTimeStamps cache
let slotOfFile = builder.GetSlotOfFileName fileName
let boundModel, timestamp = getBeforeSlot tmpState slotOfFile
let boundModel, timestamp = getBeforeSlot currentState slotOfFile
let projectTimeStamp = builder.GetLogicalTimeStampForFileInProject(fileName)
PartialCheckResults (boundModel, timestamp, projectTimeStamp)

member builder.GetCheckResultsBeforeSlotInProject slotOfFile =
node {
let cache = TimeStampCache defaultTimeStamp
do! checkFileTimeStamps cache
checkFileTimeStamps cache
let! result = evalUpToTargetSlot currentState (slotOfFile - 1)
match result with
| Some (boundModel, timestamp) ->
Expand All @@ -1196,7 +1177,7 @@ type IncrementalBuilder(initialState: IncrementalBuilderInitialState, state: Inc
member builder.GetFullCheckResultsBeforeSlotInProject slotOfFile =
node {
let cache = TimeStampCache defaultTimeStamp
do! checkFileTimeStamps cache
checkFileTimeStamps cache
let! result = evalUpToTargetSlot currentState (slotOfFile - 1)
match result with
| Some (boundModel, timestamp) ->
Expand Down Expand Up @@ -1231,7 +1212,7 @@ type IncrementalBuilder(initialState: IncrementalBuilderInitialState, state: Inc
member builder.GetCheckResultsAndImplementationsForProject() =
node {
let cache = TimeStampCache(defaultTimeStamp)
do! checkFileTimeStamps cache
checkFileTimeStamps cache
let! result = currentState.finalizedBoundModel.GetOrComputeValue()
match result with
| (ilAssemRef, tcAssemblyDataOpt, tcAssemblyExprOpt, boundModel), timestamp ->
Expand All @@ -1254,12 +1235,12 @@ type IncrementalBuilder(initialState: IncrementalBuilderInitialState, state: Inc

member _.GetLogicalTimeStampForFileInProject(slotOfFile: int) =
let cache = TimeStampCache defaultTimeStamp
let tempState = computeStampedFileNames initialState currentState cache
computeProjectTimeStamp tempState slotOfFile
checkFileTimeStamps cache
computeProjectTimeStamp currentState slotOfFile

member _.GetLogicalTimeStampForProject(cache) =
let tempState = computeStampedFileNames initialState currentState cache
computeProjectTimeStamp tempState -1
checkFileTimeStamps cache
computeProjectTimeStamp currentState -1

member _.TryGetSlotOfFileName(fileName: string) =
// Get the slot of the given file and force it to build.
Expand Down Expand Up @@ -1293,11 +1274,10 @@ type IncrementalBuilder(initialState: IncrementalBuilderInitialState, state: Inc
node {
let slotOfFile = builder.GetSlotOfFileName fileName
let cache = TimeStampCache defaultTimeStamp
let! ct = NodeCode.CancellationToken
do! setCurrentState
{ currentState with
slots = currentState.slots |> List.updateAt slotOfFile (currentState.slots[slotOfFile].Notify timeStamp) }
cache ct
setCurrentState
{ currentState with
slots = currentState.slots |> List.updateAt slotOfFile (currentState.slots[slotOfFile].Notify timeStamp) }
cache
}

member _.SourceFiles = fileNames |> Seq.map (fun f -> f.Source.FilePath) |> List.ofSeq
Expand Down