@@ -222,6 +222,9 @@ package final actor SemanticIndexManager {
222222 /// The parameter is the number of files that were scheduled to be indexed.
223223 private let indexTasksWereScheduled : @Sendable ( _ numberOfFileScheduled: Int ) -> Void
224224
225+ /// The number of tasks to prepare concurrently, whenever a index request is scheduled.
226+ private let indexTaskBatchSize : Int
227+
225228 /// Callback that is called when `progressStatus` might have changed.
226229 private let indexProgressStatusDidChange : @Sendable ( ) -> Void
227230
@@ -261,6 +264,7 @@ package final actor SemanticIndexManager {
261264 updateIndexStoreTimeout: Duration ,
262265 hooks: IndexHooks ,
263266 indexTaskScheduler: TaskScheduler < AnyIndexTaskDescription > ,
267+ indexTaskBatchSize: Int ,
264268 logMessageToIndexLog:
265269 @escaping @Sendable (
266270 _ message: String , _ type: WindowMessageType , _ structure: StructuredLogKind
@@ -273,6 +277,7 @@ package final actor SemanticIndexManager {
273277 self . updateIndexStoreTimeout = updateIndexStoreTimeout
274278 self . hooks = hooks
275279 self . indexTaskScheduler = indexTaskScheduler
280+ self . indexTaskBatchSize = indexTaskBatchSize
276281 self . logMessageToIndexLog = logMessageToIndexLog
277282 self . indexTasksWereScheduled = indexTasksWereScheduled
278283 self . indexProgressStatusDidChange = indexProgressStatusDidChange
@@ -877,10 +882,7 @@ package final actor SemanticIndexManager {
877882
878883 var indexTasks : [ Task < Void , Never > ] = [ ]
879884
880- // TODO: When we can index multiple targets concurrently in SwiftPM, increase the batch size to half the
881- // processor count, so we can get parallelism during preparation.
882- // (https://github.com/swiftlang/sourcekit-lsp/issues/1262)
883- for targetsBatch in sortedTargets. partition ( intoBatchesOfSize: 1 ) {
885+ for targetsBatch in sortedTargets. partition ( intoBatchesOfSize: indexTaskBatchSize) {
884886 let preparationTaskID = UUID ( )
885887 let filesToIndex = targetsBatch. flatMap ( { filesByTarget [ $0] ! } )
886888
0 commit comments