better invalidation for schedule cache (only on relevant changes);
authorFabian Huch <huch@in.tum.de>
Mon, 13 Nov 2023 17:48:11 +0100
changeset 78975 4a5d35b35aeb
parent 78974 9e963cd24fd2
child 78976 8da0eedd562c
better invalidation for schedule cache (only on relevant changes);
src/Pure/Tools/build_schedule.scala
--- a/src/Pure/Tools/build_schedule.scala	Mon Nov 13 17:31:37 2023 +0100
+++ b/src/Pure/Tools/build_schedule.scala	Mon Nov 13 17:48:11 2023 +0100
@@ -576,9 +576,10 @@
     /* build process */
 
     case class Cache(state: Build_Process.State, configs: List[Config], estimate: Date) {
-      def is_current(state: Build_Process.State): Boolean = this.state == state
+      def is_current(state: Build_Process.State): Boolean =
+        this.state.pending.nonEmpty && this.state.results == state.results
       def is_current_estimate(estimate: Date): Boolean =
-        this.estimate.time - estimate.time >= Time.seconds(1)
+        Math.abs((this.estimate.time - estimate.time).ms) < Time.minutes(1).ms
     }
 
     private var cache = Cache(Build_Process.State(), Nil, Date.now())
@@ -617,7 +618,7 @@
       val finalize_limit = if (build_context.master) Int.MaxValue else 0
 
       if (progress.stopped) state.ready.map(_.name).take(finalize_limit)
-      else if (cache.is_current(state)) cache.configs.map(_.job_name)
+      else if (cache.is_current(state)) cache.configs.map(_.job_name).filterNot(state.is_running)
       else {
         val current = state.ready.filter(task => is_current(state, task.name))
         if (current.nonEmpty) current.map(_.name).take(finalize_limit)