You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/Compiler/Driver/CompilerConfig.fsi
+3Lines changed: 3 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -205,8 +205,11 @@ type ParallelReferenceResolution =
205
205
206
206
[<RequireQualifiedAccess>]
207
207
typeTypeCheckingMode=
208
+
/// Default mode where all source files are processed sequentially in compilation order.
208
209
| Sequential
210
+
/// Signature files and implementation files without backing files are processed sequentially, then backed implementation files are processed in parallel.
209
211
| ParallelCheckingOfBackedImplFiles
212
+
/// Parallel type-checking that uses automated file-to-file dependency detection to construct a highly-parallelisable file graph.
// Keep number of items running & queue of items to run later
24
-
// NOTE: We keep an explicit queue, so that we can e.g. start dropping
25
-
// items if there are too many requests (or do something else)
26
-
// NOTE: The loop is only accessed from one thread at each time
27
-
// so we can just use non-thread-safe queue & mutation
28
-
letqueue= Queue<_>()
29
-
let mutablecount=0
30
-
31
-
whiletruedo
32
-
let!msg= inbox.Receive()
33
-
// When we receive Start, add the work to the queue
34
-
// When we receive Finished, do count--
35
-
match msg with
36
-
| Start work -> queue.Enqueue(work)
37
-
| Finished -> count <- count +1
38
-
// After something happened, we check if we can
39
-
// start a next task from the queue
40
-
if count < limit && queue.Count >0then
41
-
count <- count +1
42
-
letwork= queue.Dequeue()
43
-
// Start it in a thread pool (on background)
44
-
Async.Start(
45
-
async{
46
-
do! work
47
-
inbox.Post(Finished)
48
-
}
49
-
)
50
-
}
51
-
52
-
MailboxProcessor.Start(act, ct)
53
-
54
-
// TODO Test this version
55
-
/// Untested version that uses MailboxProcessor.
56
-
/// See http://www.fssnip.net/nX/title/Limit-degree-of-parallelism-using-an-agent for implementation
57
-
letprocessInParallelUsingMailbox
58
-
(firstItems:'Item[])
59
-
(work:'Item ->Async<'Item[]>)
60
-
(parallelism:int)
61
-
(notify:int ->unit)
62
-
(ct:CancellationToken)
63
-
:unit =
64
-
letprocessedCountLock= Object()
65
-
let mutableprocessedCount=0
66
-
letagent= threadingLimitAgent parallelism ct
67
-
68
-
let recprocessItem item =
69
-
async{
70
-
let!toSchedule= work item
71
-
72
-
letpc=
73
-
lock processedCountLock (fun()->
74
-
processedCount <- processedCount +1
75
-
processedCount)
76
-
77
-
notify pc
78
-
toSchedule |> Array.iter (fun x -> agent.Post(Start(processItem x)))
79
-
}
80
-
81
-
firstItems |> Array.iter (fun x -> agent.Post(Start(processItem x)))
82
-
83
9
// TODO Could replace with MailboxProcessor+Tasks/Asyncs instead of BlockingCollection + Threads
84
10
// See http://www.fssnip.net/nX/title/Limit-degree-of-parallelism-using-an-agent
85
11
/// Process items in parallel, allow more work to be scheduled as a result of finished work,
@@ -88,51 +14,38 @@ let processInParallel
88
14
(firstItems:'Item[])
89
15
(work:'Item ->'Item[])
90
16
(parallelism:int)
91
-
(stop:int ->bool)
17
+
(shouldStop:int ->bool)
92
18
(ct:CancellationToken)
93
-
(_itemToString)
19
+
(_itemToString:'Item ->string)
94
20
:unit =
95
21
letbc=new BlockingCollection<'Item>()
96
22
firstItems |> Array.iter bc.Add
97
23
letprocessedCountLock= Object()
98
24
let mutableprocessedCount=0
99
25
100
26
letprocessItem item =
101
-
// printfn $"Processing {itemToString item}"
27
+
printfn $"Processing {_itemToString item}"
102
28
lettoSchedule= work item
103
29
104
30
letprocessedCount=
105
31
lock processedCountLock (fun()->
106
32
processedCount <- processedCount +1
107
33
processedCount)
108
-
// printfn $"ToSchedule {toSchedule.Length}"
109
-
toSchedule |> Array.iter (fun next -> bc.Add(next))
0 commit comments