Skip to content

Commit 6a132ad

Browse files
committed
Remove status logging from TaskScheduler
The logging from `TaskScheduler` was really verbose (and somewhat useful during its development) but it turns out that it’s just noise in real-world debugging. So, let’s remove it.
1 parent 490871b commit 6a132ad

File tree

1 file changed

+10
-44
lines changed

1 file changed

+10
-44
lines changed

Sources/SKCore/TaskScheduler.swift

Lines changed: 10 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ public enum TaskDependencyAction<TaskDescription: TaskDescriptionProtocol> {
2020
case cancelAndRescheduleDependency(TaskDescription)
2121
}
2222

23-
private let taskSchedulerSubsystem = "org.swift.sourcekit-lsp.task-scheduler"
24-
2523
public protocol TaskDescriptionProtocol: Identifiable, Sendable, CustomLogStringConvertible {
2624
/// Execute the task.
2725
///
@@ -259,11 +257,6 @@ fileprivate actor QueuedTask<TaskDescription: TaskDescriptionProtocol> {
259257
/// a new task that depends on it. Otherwise a no-op.
260258
nonisolated func elevatePriority(to targetPriority: TaskPriority) {
261259
if priority < targetPriority {
262-
withLoggingSubsystemAndScope(subsystem: taskSchedulerSubsystem, scope: nil) {
263-
logger.debug(
264-
"Elevating priority of \(self.description.forLogging) from \(self.priority.rawValue) to \(targetPriority.rawValue)"
265-
)
266-
}
267260
Task(priority: targetPriority) {
268261
await self.resultTask.value
269262
}
@@ -336,9 +329,6 @@ public actor TaskScheduler<TaskDescription: TaskDescriptionProtocol> {
336329
_ taskDescription: TaskDescription,
337330
@_inheritActorContext executionStateChangedCallback: (@Sendable (TaskExecutionState) async -> Void)? = nil
338331
) async -> Task<Void, Never> {
339-
withLoggingSubsystemAndScope(subsystem: taskSchedulerSubsystem, scope: nil) {
340-
logger.debug("Scheduling \(taskDescription.forLogging)")
341-
}
342332
let queuedTask = await QueuedTask(
343333
priority: priority,
344334
description: taskDescription,
@@ -397,17 +387,13 @@ public actor TaskScheduler<TaskDescription: TaskDescriptionProtocol> {
397387
case .cancelAndRescheduleDependency(let taskDescription):
398388
guard let dependency = self.currentlyExecutingTasks.first(where: { $0.description.id == taskDescription.id })
399389
else {
400-
withLoggingSubsystemAndScope(subsystem: taskSchedulerSubsystem, scope: nil) {
401-
logger.fault(
402-
"Cannot find task to wait for \(taskDescription.forLogging) in list of currently executing tasks"
403-
)
404-
}
390+
logger.fault(
391+
"Cannot find task to wait for \(taskDescription.forLogging) in list of currently executing tasks"
392+
)
405393
return nil
406394
}
407395
if !taskDescription.isIdempotent {
408-
withLoggingSubsystemAndScope(subsystem: taskSchedulerSubsystem, scope: nil) {
409-
logger.fault("Cannot reschedule task '\(taskDescription.forLogging)' since it is not idempotent")
410-
}
396+
logger.fault("Cannot reschedule task '\(taskDescription.forLogging)' since it is not idempotent")
411397
return dependency
412398
}
413399
if dependency.priority > task.priority {
@@ -418,11 +404,9 @@ public actor TaskScheduler<TaskDescription: TaskDescriptionProtocol> {
418404
case .waitAndElevatePriorityOfDependency(let taskDescription):
419405
guard let dependency = self.currentlyExecutingTasks.first(where: { $0.description.id == taskDescription.id })
420406
else {
421-
withLoggingSubsystemAndScope(subsystem: taskSchedulerSubsystem, scope: nil) {
422-
logger.fault(
423-
"Cannot find task to wait for '\(taskDescription.forLogging)' in list of currently executing tasks"
424-
)
425-
}
407+
logger.fault(
408+
"Cannot find task to wait for '\(taskDescription.forLogging)' in list of currently executing tasks"
409+
)
426410
return nil
427411
}
428412
return dependency
@@ -440,11 +424,9 @@ public actor TaskScheduler<TaskDescription: TaskDescriptionProtocol> {
440424
switch taskDependency {
441425
case .cancelAndRescheduleDependency(let taskDescription):
442426
guard let task = self.currentlyExecutingTasks.first(where: { $0.description.id == taskDescription.id }) else {
443-
withLoggingSubsystemAndScope(subsystem: taskSchedulerSubsystem, scope: nil) {
444-
logger.fault(
445-
"Cannot find task to reschedule \(taskDescription.forLogging) in list of currently executing tasks"
446-
)
447-
}
427+
logger.fault(
428+
"Cannot find task to reschedule \(taskDescription.forLogging) in list of currently executing tasks"
429+
)
448430
return nil
449431
}
450432
return task
@@ -455,9 +437,6 @@ public actor TaskScheduler<TaskDescription: TaskDescriptionProtocol> {
455437
if !rescheduleTasks.isEmpty {
456438
Task.detached(priority: task.priority) {
457439
for task in rescheduleTasks {
458-
withLoggingSubsystemAndScope(subsystem: taskSchedulerSubsystem, scope: nil) {
459-
logger.debug("Suspending \(task.description.forLogging)")
460-
}
461440
await task.cancelToBeRescheduled()
462441
}
463442
}
@@ -468,25 +447,12 @@ public actor TaskScheduler<TaskDescription: TaskDescriptionProtocol> {
468447
return
469448
}
470449

471-
withLoggingSubsystemAndScope(subsystem: taskSchedulerSubsystem, scope: nil) {
472-
logger.debug("Executing \(task.description.forLogging) with priority \(task.priority.rawValue)")
473-
}
474450
currentlyExecutingTasks.append(task)
475451
pendingTasks.removeAll(where: { $0 === task })
476452
Task.detached(priority: task.priority) {
477-
withLoggingSubsystemAndScope(subsystem: taskSchedulerSubsystem, scope: nil) {
478-
logger.debug(
479-
"Execution of \(task.description.forLogging) started with priority \(Task.currentPriority.rawValue)"
480-
)
481-
}
482453
// Await the task's return in a task so that this poker can continue checking if there are more execution
483454
// slots that can be filled with queued tasks.
484455
let finishStatus = await task.execute()
485-
withLoggingSubsystemAndScope(subsystem: taskSchedulerSubsystem, scope: nil) {
486-
logger.debug(
487-
"Execution of \(task.description.forLogging) finished with priority \(Task.currentPriority.rawValue)"
488-
)
489-
}
490456
await self.finalizeTaskExecution(task: task, finishStatus: finishStatus)
491457
}
492458
}

0 commit comments

Comments
 (0)