Skip to content

Commit

Permalink
fix(core): schedule tasks with the most tasks that depend on it first
Browse files Browse the repository at this point in the history
Tasks should be scheduled by how many other tasks depend on it,
to avoid bottlenecks.
  • Loading branch information
skrtheboss committed Nov 3, 2022
1 parent a146745 commit f794637
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/nx/src/tasks-runner/tasks-schedule.ts
Expand Up @@ -99,7 +99,14 @@ export class TasksSchedule {
[taskId]
);
this.options.lifeCycle.scheduleTask(task);
this.scheduledTasks.push(taskId);
this.scheduledTasks = this.scheduledTasks
.concat(taskId)
// NOTE: sort task by most dependent on first
.sort(
(taskId1, taskId2) =>
this.reverseTaskDeps[taskId2].length -
this.reverseTaskDeps[taskId1].length
);
}

private scheduleBatches() {
Expand Down

0 comments on commit f794637

Please sign in to comment.