@@ -145,15 +145,6 @@ private struct InProgressPrepareForEditorTask {
145145 let task : Task < Void , Never >
146146}
147147
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-
157148/// An entry in `SemanticIndexManager.inProgressPreparationTasks`.
158149private struct InProgressPreparationTask {
159150 let task : OpaqueQueuedIndexTask
@@ -222,8 +213,8 @@ package final actor SemanticIndexManager {
222213 /// The parameter is the number of files that were scheduled to be indexed.
223214 private let indexTasksWereScheduled : @Sendable ( _ numberOfFileScheduled: Int ) -> Void
224215
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
227218
228219 /// Callback that is called when `progressStatus` might have changed.
229220 private let indexProgressStatusDidChange : @Sendable ( ) -> Void
@@ -264,7 +255,7 @@ package final actor SemanticIndexManager {
264255 updateIndexStoreTimeout: Duration ,
265256 hooks: IndexHooks ,
266257 indexTaskScheduler: TaskScheduler < AnyIndexTaskDescription > ,
267- shouldIndexInParallel : Bool ,
258+ indexTaskBatchSize : Int ,
268259 logMessageToIndexLog:
269260 @escaping @Sendable (
270261 _ message: String , _ type: WindowMessageType , _ structure: StructuredLogKind
@@ -277,7 +268,7 @@ package final actor SemanticIndexManager {
277268 self . updateIndexStoreTimeout = updateIndexStoreTimeout
278269 self . hooks = hooks
279270 self . indexTaskScheduler = indexTaskScheduler
280- self . shouldIndexInParallel = shouldIndexInParallel
271+ self . indexTaskBatchSize = indexTaskBatchSize
281272 self . logMessageToIndexLog = logMessageToIndexLog
282273 self . indexTasksWereScheduled = indexTasksWereScheduled
283274 self . indexProgressStatusDidChange = indexProgressStatusDidChange
@@ -660,6 +651,7 @@ package final actor SemanticIndexManager {
660651 targetsToPrepare: targetsToPrepare,
661652 buildServerManager: self . buildServerManager,
662653 preparationUpToDateTracker: preparationUpToDateTracker,
654+ purpose: purpose,
663655 logMessageToIndexLog: logMessageToIndexLog,
664656 hooks: hooks
665657 )
@@ -882,14 +874,7 @@ package final actor SemanticIndexManager {
882874
883875 var indexTasks : [ Task < Void , Never > ] = [ ]
884876
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) {
893878 let preparationTaskID = UUID ( )
894879 let filesToIndex = targetsBatch. flatMap ( { filesByTarget [ $0] ! } )
895880
@@ -913,7 +898,7 @@ package final actor SemanticIndexManager {
913898 // And after preparation is done, index the files in the targets.
914899 await withTaskGroup ( of: Void . self) { taskGroup in
915900 for target in targetsBatch {
916- for fileBatch in filesByTarget [ target] !. partition ( intoBatchesOfSize: batchSize ) {
901+ for fileBatch in filesByTarget [ target] !. partition ( intoBatchesOfSize: indexTaskBatchSize ) {
917902 taskGroup. addTask {
918903 await self . updateIndexStore (
919904 for: fileBatch,
0 commit comments