Skip to content

Commit

Permalink
chore(core): wip
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenPandaz committed Sep 26, 2024
1 parent 7da6f85 commit 40d8197
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions packages/nx/src/tasks-runner/tasks-schedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class TasksSchedule {
private completedTasks = new Set<string>();
private scheduleRequestsExecutionChain = Promise.resolve();
private estimatedTaskTimings: Record<string, number> = {};
private projectDependencies: Record<string, number> = {};

constructor(
private readonly projectGraph: ProjectGraph,
Expand All @@ -42,6 +43,15 @@ export class TasksSchedule {
Object.values(this.taskGraph.tasks).map((t) => t.target)
);
}

for (const project of Object.values(this.taskGraph.tasks).map(
(t) => t.target.project
)) {
this.projectDependencies[project] ??= findAllProjectNodeDependencies(
project,
this.reverseProjectGraph
).length;
}
}

public async scheduleNextTasks() {
Expand Down Expand Up @@ -125,14 +135,8 @@ export class TasksSchedule {
const project1 = this.taskGraph.tasks[taskId1].target.project;
const project2 = this.taskGraph.tasks[taskId2].target.project;

const project1NodeDependencies = findAllProjectNodeDependencies(
project1,
this.reverseProjectGraph
).length;
const project2NodeDependencies = findAllProjectNodeDependencies(
project2,
this.reverseProjectGraph
).length;
const project1NodeDependencies = this.projectDependencies[project1];
const project2NodeDependencies = this.projectDependencies[project2];

const dependenciesDiff =
project2NodeDependencies - project1NodeDependencies;
Expand Down

0 comments on commit 40d8197

Please sign in to comment.