src/Pure/Tools/build_schedule.scala
changeset 79184 b5b5930bd40a
parent 79183 32d00ec387f4
child 79185 cfed4fcf1dae
equal deleted inserted replaced
79183:32d00ec387f4 79184:b5b5930bd40a
    61         }
    61         }
    62 
    62 
    63       def linear(p0: (Int, Time), p1: (Int, Time)): Time = {
    63       def linear(p0: (Int, Time), p1: (Int, Time)): Time = {
    64         val a = (p1._2 - p0._2).scale(1.0 / (p1._1 - p0._1))
    64         val a = (p1._2 - p0._2).scale(1.0 / (p1._1 - p0._1))
    65         val b = p0._2 - a.scale(p0._1)
    65         val b = p0._2 - a.scale(p0._1)
    66         Time.ms((a.scale(threads) + b).ms max 0)
    66         (a.scale(threads) + b) max Time.zero
    67       }
    67       }
    68 
    68 
    69       val mono_prefix = sorted_prefix(entries, e => -e._2.ms)
    69       val mono_prefix = sorted_prefix(entries, e => -e._2.ms)
    70 
    70 
    71       val is_mono = entries == mono_prefix
    71       val is_mono = entries == mono_prefix
    81             if m != n
    81             if m != n
    82           } yield (t0 - t1).scale(n.toDouble * m / (m - n)))
    82           } yield (t0 - t1).scale(n.toDouble * m / (m - n)))
    83         val t_c =
    83         val t_c =
    84           Timing_Data.median_time(for ((n, t) <- mono_prefix) yield t - t_p.scale(1.0 / n))
    84           Timing_Data.median_time(for ((n, t) <- mono_prefix) yield t - t_p.scale(1.0 / n))
    85 
    85 
    86         def model(threads: Int): Time = Time.ms((t_c + t_p.scale(1.0 / threads)).ms max 0)
    86         def model(threads: Int): Time = (t_c + t_p.scale(1.0 / threads)) max Time.zero
    87 
    87 
    88         if (is_mono || in_prefix) model(threads)
    88         if (is_mono || in_prefix) model(threads)
    89         else {
    89         else {
    90           val post_inflection = entries.drop(mono_prefix.length).head
    90           val post_inflection = entries.drop(mono_prefix.length).head
    91           val inflection_threads = inflection_point(mono_prefix.last._1, post_inflection._1)
    91           val inflection_threads = inflection_point(mono_prefix.last._1, post_inflection._1)
   692           case None => node -> best_time(node)
   692           case None => node -> best_time(node)
   693           case Some(job) =>
   693           case Some(job) =>
   694             val estimate =
   694             val estimate =
   695               timing_data.estimate(job.name, job.node_info.hostname,
   695               timing_data.estimate(job.name, job.node_info.hostname,
   696                 host_infos.num_threads(job.node_info))
   696                 host_infos.num_threads(job.node_info))
   697             node -> Time.ms((Time.now() - job.start_date.time + estimate).ms max 0)
   697             node -> ((Time.now() - job.start_date.time + estimate) max Time.zero)
   698         }
   698         }
   699 
   699 
   700       val max_parallel = parallel_paths(state.ready.map(_.name).map(remaining_time))
   700       val max_parallel = parallel_paths(state.ready.map(_.name).map(remaining_time))
   701       val next_sorted = state.next_ready.sortBy(max_time(_).ms).reverse
   701       val next_sorted = state.next_ready.sortBy(max_time(_).ms).reverse
   702 
   702