@@ -145,15 +145,6 @@ private struct InProgressPrepareForEditorTask {
145
145
let task : Task < Void , Never >
146
146
}
147
147
148
- /// The reason why a target is being prepared. This is used to determine the `IndexProgressStatus`.
149
- private enum TargetPreparationPurpose : Comparable {
150
- /// We are preparing the target so we can index files in it.
151
- case forIndexing
152
-
153
- /// We are preparing the target to provide semantic functionality in one of its files.
154
- case forEditorFunctionality
155
- }
156
-
157
148
/// An entry in `SemanticIndexManager.inProgressPreparationTasks`.
158
149
private struct InProgressPreparationTask {
159
150
let task : OpaqueQueuedIndexTask
@@ -222,8 +213,8 @@ package final actor SemanticIndexManager {
222
213
/// The parameter is the number of files that were scheduled to be indexed.
223
214
private let indexTasksWereScheduled : @Sendable ( _ numberOfFileScheduled: Int ) -> Void
224
215
225
- /// Determines whether or not the `SemanticIndexManager` should dispatch preparation tasks in batches .
226
- private let shouldIndexInParallel : Bool
216
+ /// The size of the batches in which the `SemanticIndexManager` should dispatch preparation tasks.
217
+ private let indexTaskBatchSize : Int
227
218
228
219
/// Callback that is called when `progressStatus` might have changed.
229
220
private let indexProgressStatusDidChange : @Sendable ( ) -> Void
@@ -264,7 +255,7 @@ package final actor SemanticIndexManager {
264
255
updateIndexStoreTimeout: Duration ,
265
256
hooks: IndexHooks ,
266
257
indexTaskScheduler: TaskScheduler < AnyIndexTaskDescription > ,
267
- shouldIndexInParallel : Bool ,
258
+ indexTaskBatchSize : Int ,
268
259
logMessageToIndexLog:
269
260
@escaping @Sendable (
270
261
_ message: String , _ type: WindowMessageType , _ structure: StructuredLogKind
@@ -277,7 +268,7 @@ package final actor SemanticIndexManager {
277
268
self . updateIndexStoreTimeout = updateIndexStoreTimeout
278
269
self . hooks = hooks
279
270
self . indexTaskScheduler = indexTaskScheduler
280
- self . shouldIndexInParallel = shouldIndexInParallel
271
+ self . indexTaskBatchSize = indexTaskBatchSize
281
272
self . logMessageToIndexLog = logMessageToIndexLog
282
273
self . indexTasksWereScheduled = indexTasksWereScheduled
283
274
self . indexProgressStatusDidChange = indexProgressStatusDidChange
@@ -660,6 +651,7 @@ package final actor SemanticIndexManager {
660
651
targetsToPrepare: targetsToPrepare,
661
652
buildServerManager: self . buildServerManager,
662
653
preparationUpToDateTracker: preparationUpToDateTracker,
654
+ purpose: purpose,
663
655
logMessageToIndexLog: logMessageToIndexLog,
664
656
hooks: hooks
665
657
)
@@ -882,14 +874,7 @@ package final actor SemanticIndexManager {
882
874
883
875
var indexTasks : [ Task < Void , Never > ] = [ ]
884
876
885
- let batchSize : Int
886
- if shouldIndexInParallel {
887
- let processorCount = ProcessInfo . processInfo. activeProcessorCount
888
- batchSize = max ( 1 , processorCount * 5 )
889
- } else {
890
- batchSize = 1
891
- }
892
- for targetsBatch in sortedTargets. partition ( intoBatchesOfSize: batchSize) {
877
+ for targetsBatch in sortedTargets. partition ( intoBatchesOfSize: indexTaskBatchSize) {
893
878
let preparationTaskID = UUID ( )
894
879
let filesToIndex = targetsBatch. flatMap ( { filesByTarget [ $0] ! } )
895
880
@@ -913,7 +898,7 @@ package final actor SemanticIndexManager {
913
898
// And after preparation is done, index the files in the targets.
914
899
await withTaskGroup ( of: Void . self) { taskGroup in
915
900
for target in targetsBatch {
916
- for fileBatch in filesByTarget [ target] !. partition ( intoBatchesOfSize: batchSize ) {
901
+ for fileBatch in filesByTarget [ target] !. partition ( intoBatchesOfSize: indexTaskBatchSize ) {
917
902
taskGroup. addTask {
918
903
await self . updateIndexStore (
919
904
for: fileBatch,
0 commit comments