introduced path heuristic abstraction;
authorFabian Huch <huch@in.tum.de>
Wed, 22 Nov 2023 15:04:29 +0100
changeset 79019 4df053d29215
parent 79018 7449ff77029e
child 79020 ef76705bf402
introduced path heuristic abstraction;
src/Pure/Tools/build_schedule.scala
--- a/src/Pure/Tools/build_schedule.scala	Wed Nov 22 17:50:36 2023 +0000
+++ b/src/Pure/Tools/build_schedule.scala	Wed Nov 22 15:04:29 2023 +0100
@@ -324,6 +324,8 @@
   }
 
   abstract class Heuristic(timing_data: Timing_Data) extends Scheduler {
+    val host_infos = timing_data.host_infos
+
     def build_duration(build_state: Build_Process.State): Time = {
       @tailrec
       def simulate(state: State): State =
@@ -352,12 +354,8 @@
 
   /* heuristics */
 
-  class Timing_Heuristic(
-    threshold: Time,
-    timing_data: Timing_Data,
-    sessions_structure: Sessions.Structure,
-    max_threads: Int = 8
-  ) extends Heuristic(timing_data) {
+  abstract class Path_Heuristic(timing_data: Timing_Data, sessions_structure: Sessions.Structure)
+    extends Heuristic(timing_data) {
     /* pre-computed properties for efficient heuristic */
 
     type Node = String
@@ -383,10 +381,6 @@
         .groupMapReduce(_._1)(_._2)(_ max _)
     }
 
-    val critical_path_nodes =
-      build_graph.keys.map(node =>
-        node -> path_times(node).filter((_, time) => time > threshold).keySet).toMap
-
     def parallel_paths(minimals: Set[Node], pred: Node => Boolean = _ => true): Int = {
       def start(node: Node): (Node, Time) = node -> best_times(node)
 
@@ -413,11 +407,17 @@
 
       parallel_paths(minimals.map(start).toMap)._1
     }
-
+  }
 
-    /* scheduling */
-
-    val host_infos = timing_data.host_infos
+  class Timing_Heuristic(
+    threshold: Time,
+    timing_data: Timing_Data,
+    sessions_structure: Sessions.Structure,
+    max_threads: Int = 8
+  ) extends Path_Heuristic(timing_data, sessions_structure) {
+    val critical_path_nodes =
+      build_graph.keys.map(node =>
+        node -> path_times(node).filter((_, time) => time > threshold).keySet).toMap
 
     def next(state: Build_Process.State): List[Config] = {
       val resources = host_infos.available(state)