@@ -222,6 +222,9 @@ package final actor SemanticIndexManager {
222
222
/// The parameter is the number of files that were scheduled to be indexed.
223
223
private let indexTasksWereScheduled : @Sendable ( _ numberOfFileScheduled: Int ) -> Void
224
224
225
+ /// The number of tasks to prepare concurrently, whenever a index request is scheduled.
226
+ private let indexTaskBatchSize : Int
227
+
225
228
/// Callback that is called when `progressStatus` might have changed.
226
229
private let indexProgressStatusDidChange : @Sendable ( ) -> Void
227
230
@@ -261,6 +264,7 @@ package final actor SemanticIndexManager {
261
264
updateIndexStoreTimeout: Duration ,
262
265
hooks: IndexHooks ,
263
266
indexTaskScheduler: TaskScheduler < AnyIndexTaskDescription > ,
267
+ indexTaskBatchSize: Int ,
264
268
logMessageToIndexLog:
265
269
@escaping @Sendable (
266
270
_ message: String , _ type: WindowMessageType , _ structure: StructuredLogKind
@@ -273,6 +277,7 @@ package final actor SemanticIndexManager {
273
277
self . updateIndexStoreTimeout = updateIndexStoreTimeout
274
278
self . hooks = hooks
275
279
self . indexTaskScheduler = indexTaskScheduler
280
+ self . indexTaskBatchSize = indexTaskBatchSize
276
281
self . logMessageToIndexLog = logMessageToIndexLog
277
282
self . indexTasksWereScheduled = indexTasksWereScheduled
278
283
self . indexProgressStatusDidChange = indexProgressStatusDidChange
@@ -877,10 +882,7 @@ package final actor SemanticIndexManager {
877
882
878
883
var indexTasks : [ Task < Void , Never > ] = [ ]
879
884
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) {
884
886
let preparationTaskID = UUID ( )
885
887
let filesToIndex = targetsBatch. flatMap ( { filesByTarget [ $0] ! } )
886
888
0 commit comments