src/Pure/Admin/build_status.scala
author wenzelm
Fri, 26 May 2017 23:33:42 +0200
changeset 65940 9c7241798c3b
parent 65939 9fb044904a4d
child 65941 316c30b60ebc
permissions -rw-r--r--
show errors from build_log database;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
65743
4847ca570454 clarified name;
wenzelm
parents: 65742
diff changeset
     1
/*  Title:      Pure/Admin/build_status.scala
63686
66f217416da7 statistics from session build output;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
66f217416da7 statistics from session build output;
wenzelm
parents:
diff changeset
     3
65743
4847ca570454 clarified name;
wenzelm
parents: 65742
diff changeset
     4
Present recent build status information from database.
63686
66f217416da7 statistics from session build output;
wenzelm
parents:
diff changeset
     5
*/
66f217416da7 statistics from session build output;
wenzelm
parents:
diff changeset
     6
66f217416da7 statistics from session build output;
wenzelm
parents:
diff changeset
     7
package isabelle
66f217416da7 statistics from session build output;
wenzelm
parents:
diff changeset
     8
66f217416da7 statistics from session build output;
wenzelm
parents:
diff changeset
     9
65743
4847ca570454 clarified name;
wenzelm
parents: 65742
diff changeset
    10
object Build_Status
63686
66f217416da7 statistics from session build output;
wenzelm
parents:
diff changeset
    11
{
65799
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
    12
  /* defaults */
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
    13
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
    14
  val default_target_dir = Path.explode("build_status")
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
    15
  val default_image_size = (800, 600)
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
    16
  val default_history = 30
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
    17
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
    18
  def default_profiles: List[Profile] =
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
    19
    Jenkins.build_status_profiles ::: Isabelle_Cronjob.build_status_profiles
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
    20
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
    21
65791
wenzelm
parents: 65786
diff changeset
    22
  /* data profiles */
wenzelm
parents: 65786
diff changeset
    23
65798
d459db0f6135 actually plot extended profile history;
wenzelm
parents: 65796
diff changeset
    24
  sealed case class Profile(description: String, history: Int, sql: String)
65791
wenzelm
parents: 65786
diff changeset
    25
  {
65799
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
    26
    def days(options: Options): Int = options.int("build_log_history") max history
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
    27
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
    28
    def stretch(options: Options): Double =
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
    29
      (days(options) max default_history min (default_history * 5)).toDouble / default_history
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
    30
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
    31
    def select(options: Options, columns: List[SQL.Column], only_sessions: Set[String]): SQL.Source =
65791
wenzelm
parents: 65786
diff changeset
    32
    {
wenzelm
parents: 65786
diff changeset
    33
      Build_Log.Data.universal_table.select(columns, distinct = true,
wenzelm
parents: 65786
diff changeset
    34
        sql = "WHERE " +
65799
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
    35
          Build_Log.Data.pull_date + " > " + Build_Log.Data.recent_time(days(options)) + " AND " +
65893
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
    36
          SQL.member(Build_Log.Data.status.ident,
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
    37
            List(
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
    38
              Build_Log.Session_Status.finished.toString,
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
    39
              Build_Log.Session_Status.failed.toString)) +
65804
wenzelm
parents: 65799
diff changeset
    40
          (if (only_sessions.isEmpty) ""
wenzelm
parents: 65799
diff changeset
    41
           else " AND " + SQL.member(Build_Log.Data.session_name.ident, only_sessions)) +
wenzelm
parents: 65799
diff changeset
    42
          " AND " + SQL.enclose(sql) +
65849
d70d2d68f7f0 proper order for entry list cons;
wenzelm
parents: 65848
diff changeset
    43
          " ORDER BY " + Build_Log.Data.pull_date)
65791
wenzelm
parents: 65786
diff changeset
    44
    }
wenzelm
parents: 65786
diff changeset
    45
  }
wenzelm
parents: 65786
diff changeset
    46
wenzelm
parents: 65786
diff changeset
    47
65785
6107504371fb tuned signature;
wenzelm
parents: 65784
diff changeset
    48
  /* build status */
6107504371fb tuned signature;
wenzelm
parents: 65784
diff changeset
    49
6107504371fb tuned signature;
wenzelm
parents: 65784
diff changeset
    50
  def build_status(options: Options,
6107504371fb tuned signature;
wenzelm
parents: 65784
diff changeset
    51
    progress: Progress = No_Progress,
6107504371fb tuned signature;
wenzelm
parents: 65784
diff changeset
    52
    profiles: List[Profile] = default_profiles,
6107504371fb tuned signature;
wenzelm
parents: 65784
diff changeset
    53
    only_sessions: Set[String] = Set.empty,
6107504371fb tuned signature;
wenzelm
parents: 65784
diff changeset
    54
    verbose: Boolean = false,
6107504371fb tuned signature;
wenzelm
parents: 65784
diff changeset
    55
    target_dir: Path = default_target_dir,
65854
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
    56
    ml_statistics: Boolean = false,
65785
6107504371fb tuned signature;
wenzelm
parents: 65784
diff changeset
    57
    image_size: (Int, Int) = default_image_size)
6107504371fb tuned signature;
wenzelm
parents: 65784
diff changeset
    58
  {
6107504371fb tuned signature;
wenzelm
parents: 65784
diff changeset
    59
    val data =
6107504371fb tuned signature;
wenzelm
parents: 65784
diff changeset
    60
      read_data(options, progress = progress, profiles = profiles,
65854
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
    61
        only_sessions = only_sessions, ml_statistics = ml_statistics, verbose = verbose)
65785
6107504371fb tuned signature;
wenzelm
parents: 65784
diff changeset
    62
6107504371fb tuned signature;
wenzelm
parents: 65784
diff changeset
    63
    present_data(data, progress = progress, target_dir = target_dir, image_size = image_size)
6107504371fb tuned signature;
wenzelm
parents: 65784
diff changeset
    64
  }
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    65
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    66
65791
wenzelm
parents: 65786
diff changeset
    67
  /* read data */
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    68
65792
c58752102b34 more output;
wenzelm
parents: 65791
diff changeset
    69
  sealed case class Data(date: Date, entries: List[Data_Entry])
65799
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
    70
  sealed case class Data_Entry(
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
    71
    name: String, hosts: List[String], stretch: Double, sessions: List[Session])
65893
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
    72
  {
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
    73
    def failed_sessions: List[Session] =
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
    74
      sessions.filter(_.head.failed).sortBy(_.name)
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
    75
  }
65865
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
    76
  sealed case class Session(
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
    77
    name: String, threads: Int, entries: List[Entry], ml_statistics: ML_Statistics)
65754
05c6a29c9132 clarified explicit Build_Status.Data operations;
wenzelm
parents: 65752
diff changeset
    78
  {
65795
c60b1a2c3abc clarified;
wenzelm
parents: 65794
diff changeset
    79
    require(entries.nonEmpty)
c60b1a2c3abc clarified;
wenzelm
parents: 65794
diff changeset
    80
65863
94fe5e82d101 tuned signature;
wenzelm
parents: 65861
diff changeset
    81
    def head: Entry = entries.head
94fe5e82d101 tuned signature;
wenzelm
parents: 65861
diff changeset
    82
    def order: Long = - head.timing.elapsed.ms
65860
ce6be2e40d47 more output;
wenzelm
parents: 65859
diff changeset
    83
65893
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
    84
    def finished_entries: List[Entry] = entries.filter(_.finished)
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
    85
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
    86
    def check_timing: Boolean = finished_entries.length >= 3
65854
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
    87
    def check_heap: Boolean =
65893
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
    88
      finished_entries.length >= 3 &&
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
    89
      finished_entries.forall(entry =>
65859
95ddb6dea0d5 plot average heap size;
wenzelm
parents: 65857
diff changeset
    90
        entry.maximum_heap > 0 ||
95ddb6dea0d5 plot average heap size;
wenzelm
parents: 65857
diff changeset
    91
        entry.average_heap > 0 ||
65866
00e8b836d4db uniform heap_scale;
wenzelm
parents: 65865
diff changeset
    92
        entry.stored_heap > 0)
65754
05c6a29c9132 clarified explicit Build_Status.Data operations;
wenzelm
parents: 65752
diff changeset
    93
  }
65854
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
    94
  sealed case class Entry(
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
    95
    pull_date: Date,
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
    96
    isabelle_version: String,
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
    97
    afp_version: String,
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
    98
    timing: Timing,
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
    99
    ml_timing: Timing,
65859
95ddb6dea0d5 plot average heap size;
wenzelm
parents: 65857
diff changeset
   100
    maximum_heap: Long,
95ddb6dea0d5 plot average heap size;
wenzelm
parents: 65857
diff changeset
   101
    average_heap: Long,
65893
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
   102
    stored_heap: Long,
65940
9c7241798c3b show errors from build_log database;
wenzelm
parents: 65939
diff changeset
   103
    status: Build_Log.Session_Status.Value,
9c7241798c3b show errors from build_log database;
wenzelm
parents: 65939
diff changeset
   104
    errors: List[String])
65893
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
   105
  {
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
   106
    def finished: Boolean = status == Build_Log.Session_Status.finished
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
   107
    def failed: Boolean = status == Build_Log.Session_Status.failed
65940
9c7241798c3b show errors from build_log database;
wenzelm
parents: 65939
diff changeset
   108
9c7241798c3b show errors from build_log database;
wenzelm
parents: 65939
diff changeset
   109
    def present_errors(name: String): XML.Body =
9c7241798c3b show errors from build_log database;
wenzelm
parents: 65939
diff changeset
   110
      if (errors.isEmpty) HTML.text(name + " (" + isabelle_version + ")")
9c7241798c3b show errors from build_log database;
wenzelm
parents: 65939
diff changeset
   111
      else {
9c7241798c3b show errors from build_log database;
wenzelm
parents: 65939
diff changeset
   112
        val tooltip_errors =
9c7241798c3b show errors from build_log database;
wenzelm
parents: 65939
diff changeset
   113
          errors.map(msg => HTML.pre(HTML.text(Symbol.decode(msg))) + HTML.error_message_class)
9c7241798c3b show errors from build_log database;
wenzelm
parents: 65939
diff changeset
   114
        val tooltip = List(HTML.div(tooltip_errors) + HTML.tooltip_class)
9c7241798c3b show errors from build_log database;
wenzelm
parents: 65939
diff changeset
   115
        HTML.span(HTML.text(name) ::: tooltip) + HTML.error_class ::
9c7241798c3b show errors from build_log database;
wenzelm
parents: 65939
diff changeset
   116
        HTML.text(" (" + isabelle_version + ")")
9c7241798c3b show errors from build_log database;
wenzelm
parents: 65939
diff changeset
   117
      }
65893
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
   118
  }
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   119
65865
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   120
  sealed case class Image(name: String, width: Int, height: Int)
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   121
  {
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   122
    def path: Path = Path.basic(name)
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   123
  }
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   124
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   125
  def read_data(options: Options,
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   126
    progress: Progress = No_Progress,
65785
6107504371fb tuned signature;
wenzelm
parents: 65784
diff changeset
   127
    profiles: List[Profile] = default_profiles,
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   128
    only_sessions: Set[String] = Set.empty,
65854
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
   129
    ml_statistics: Boolean = false,
65750
7f5556f4b584 added option verbose for SQL source;
wenzelm
parents: 65747
diff changeset
   130
    verbose: Boolean = false): Data =
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   131
  {
65754
05c6a29c9132 clarified explicit Build_Status.Data operations;
wenzelm
parents: 65752
diff changeset
   132
    val date = Date.now()
65792
c58752102b34 more output;
wenzelm
parents: 65791
diff changeset
   133
    var data_hosts = Map.empty[String, Set[String]]
65799
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
   134
    var data_stretch = Map.empty[String, Double]
65762
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   135
    var data_entries = Map.empty[String, Map[String, Session]]
63688
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   136
65792
c58752102b34 more output;
wenzelm
parents: 65791
diff changeset
   137
    def get_hosts(data_name: String): Set[String] =
c58752102b34 more output;
wenzelm
parents: 65791
diff changeset
   138
      data_hosts.getOrElse(data_name, Set.empty)
c58752102b34 more output;
wenzelm
parents: 65791
diff changeset
   139
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   140
    val store = Build_Log.store(options)
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   141
    using(store.open_database())(db =>
64089
10d719dbb3ee more permissive timing data;
wenzelm
parents: 64085
diff changeset
   142
    {
65764
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   143
      for (profile <- profiles.sortBy(_.description)) {
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   144
        progress.echo("input " + quote(profile.description))
65854
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
   145
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   146
        val columns =
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   147
          List(
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   148
            Build_Log.Data.pull_date,
65792
c58752102b34 more output;
wenzelm
parents: 65791
diff changeset
   149
            Build_Log.Prop.build_host,
65796
7d1c5150af70 more output;
wenzelm
parents: 65795
diff changeset
   150
            Build_Log.Prop.isabelle_version,
7d1c5150af70 more output;
wenzelm
parents: 65795
diff changeset
   151
            Build_Log.Prop.afp_version,
65752
ed7b5cd3a7f2 more uniform threads value, notably for Pure session;
wenzelm
parents: 65751
diff changeset
   152
            Build_Log.Settings.ISABELLE_BUILD_OPTIONS,
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   153
            Build_Log.Settings.ML_PLATFORM,
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   154
            Build_Log.Data.session_name,
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   155
            Build_Log.Data.threads,
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   156
            Build_Log.Data.timing_elapsed,
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   157
            Build_Log.Data.timing_cpu,
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   158
            Build_Log.Data.timing_gc,
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   159
            Build_Log.Data.ml_timing_elapsed,
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   160
            Build_Log.Data.ml_timing_cpu,
65769
490b7c517000 plot heap size;
wenzelm
parents: 65766
diff changeset
   161
            Build_Log.Data.ml_timing_gc,
65893
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
   162
            Build_Log.Data.heap_size,
65940
9c7241798c3b show errors from build_log database;
wenzelm
parents: 65939
diff changeset
   163
            Build_Log.Data.status,
9c7241798c3b show errors from build_log database;
wenzelm
parents: 65939
diff changeset
   164
            Build_Log.Data.errors) :::
65854
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
   165
          (if (ml_statistics) List(Build_Log.Data.ml_statistics) else Nil)
63700
2a95d904672e clarified options and arguments;
wenzelm
parents: 63688
diff changeset
   166
65752
ed7b5cd3a7f2 more uniform threads value, notably for Pure session;
wenzelm
parents: 65751
diff changeset
   167
        val Threads_Option = """threads\s*=\s*(\d+)""".r
ed7b5cd3a7f2 more uniform threads value, notably for Pure session;
wenzelm
parents: 65751
diff changeset
   168
65799
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
   169
        val sql = profile.select(options, columns, only_sessions)
65750
7f5556f4b584 added option verbose for SQL source;
wenzelm
parents: 65747
diff changeset
   170
        if (verbose) progress.echo(sql)
7f5556f4b584 added option verbose for SQL source;
wenzelm
parents: 65747
diff changeset
   171
7f5556f4b584 added option verbose for SQL source;
wenzelm
parents: 65747
diff changeset
   172
        db.using_statement(sql)(stmt =>
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   173
        {
65740
83388f09e9ab clarified signature;
wenzelm
parents: 65737
diff changeset
   174
          val res = stmt.execute_query()
83388f09e9ab clarified signature;
wenzelm
parents: 65737
diff changeset
   175
          while (res.next()) {
65766
2edb89630a80 more specific workaround (see also ed7b5cd3a7f2);
wenzelm
parents: 65765
diff changeset
   176
            val session_name = res.string(Build_Log.Data.session_name)
65764
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   177
            val threads =
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   178
            {
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   179
              val threads1 =
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   180
                res.string(Build_Log.Settings.ISABELLE_BUILD_OPTIONS) match {
65895
744878d72021 more general workaround for failed sessions (again, see also 2edb89630a80, ed7b5cd3a7f2);
wenzelm
parents: 65893
diff changeset
   181
                  case Threads_Option(Value.Int(i)) => i
65764
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   182
                  case _ => 1
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   183
                }
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   184
              val threads2 = res.get_int(Build_Log.Data.threads).getOrElse(1)
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   185
              threads1 max threads2
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   186
            }
65766
2edb89630a80 more specific workaround (see also ed7b5cd3a7f2);
wenzelm
parents: 65765
diff changeset
   187
            val ml_platform = res.string(Build_Log.Settings.ML_PLATFORM)
65762
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   188
            val data_name =
65764
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   189
              profile.description +
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   190
                (if (ml_platform.startsWith("x86_64")) ", 64bit" else "") +
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   191
                (if (threads == 1) "" else ", " + threads + " threads")
63703
ec095a532a2b provide index.html;
wenzelm
parents: 63702
diff changeset
   192
65799
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
   193
            res.get_string(Build_Log.Prop.build_host).foreach(host =>
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
   194
              data_hosts += (data_name -> (get_hosts(data_name) + host)))
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
   195
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
   196
            data_stretch += (data_name -> profile.stretch(options))
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
   197
65854
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
   198
            val isabelle_version = res.string(Build_Log.Prop.isabelle_version)
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
   199
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
   200
            val ml_stats =
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
   201
              ML_Statistics(
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
   202
                if (ml_statistics)
65857
5d29d93766ef clarified use of XML.Cache;
wenzelm
parents: 65854
diff changeset
   203
                  Properties.uncompress(res.bytes(Build_Log.Data.ml_statistics))
65866
00e8b836d4db uniform heap_scale;
wenzelm
parents: 65865
diff changeset
   204
                else Nil, heading = session_name + " (Isabelle/" + isabelle_version + ")")
65854
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
   205
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   206
            val entry =
65796
7d1c5150af70 more output;
wenzelm
parents: 65795
diff changeset
   207
              Entry(
7d1c5150af70 more output;
wenzelm
parents: 65795
diff changeset
   208
                pull_date = res.date(Build_Log.Data.pull_date),
65854
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
   209
                isabelle_version = isabelle_version,
65796
7d1c5150af70 more output;
wenzelm
parents: 65795
diff changeset
   210
                afp_version = res.string(Build_Log.Prop.afp_version),
7d1c5150af70 more output;
wenzelm
parents: 65795
diff changeset
   211
                timing =
7d1c5150af70 more output;
wenzelm
parents: 65795
diff changeset
   212
                  res.timing(
7d1c5150af70 more output;
wenzelm
parents: 65795
diff changeset
   213
                    Build_Log.Data.timing_elapsed,
7d1c5150af70 more output;
wenzelm
parents: 65795
diff changeset
   214
                    Build_Log.Data.timing_cpu,
7d1c5150af70 more output;
wenzelm
parents: 65795
diff changeset
   215
                    Build_Log.Data.timing_gc),
7d1c5150af70 more output;
wenzelm
parents: 65795
diff changeset
   216
                ml_timing =
7d1c5150af70 more output;
wenzelm
parents: 65795
diff changeset
   217
                  res.timing(
7d1c5150af70 more output;
wenzelm
parents: 65795
diff changeset
   218
                    Build_Log.Data.ml_timing_elapsed,
7d1c5150af70 more output;
wenzelm
parents: 65795
diff changeset
   219
                    Build_Log.Data.ml_timing_cpu,
7d1c5150af70 more output;
wenzelm
parents: 65795
diff changeset
   220
                    Build_Log.Data.ml_timing_gc),
65859
95ddb6dea0d5 plot average heap size;
wenzelm
parents: 65857
diff changeset
   221
                maximum_heap = ml_stats.maximum_heap_size,
95ddb6dea0d5 plot average heap size;
wenzelm
parents: 65857
diff changeset
   222
                average_heap = ml_stats.average_heap_size,
65893
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
   223
                stored_heap = ML_Statistics.heap_scale(res.long(Build_Log.Data.heap_size)),
65940
9c7241798c3b show errors from build_log database;
wenzelm
parents: 65939
diff changeset
   224
                status = Build_Log.Session_Status.withName(res.string(Build_Log.Data.status)),
9c7241798c3b show errors from build_log database;
wenzelm
parents: 65939
diff changeset
   225
                errors = Build_Log.uncompress_errors(res.bytes(Build_Log.Data.errors)))
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   226
65762
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   227
            val sessions = data_entries.getOrElse(data_name, Map.empty)
65766
2edb89630a80 more specific workaround (see also ed7b5cd3a7f2);
wenzelm
parents: 65765
diff changeset
   228
            val entries = sessions.get(session_name).map(_.entries) getOrElse Nil
65865
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   229
            val session = Session(session_name, threads, entry :: entries, ml_stats)
65766
2edb89630a80 more specific workaround (see also ed7b5cd3a7f2);
wenzelm
parents: 65765
diff changeset
   230
            data_entries += (data_name -> (sessions + (session_name -> session)))
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   231
          }
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   232
        })
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   233
      }
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   234
    })
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   235
65792
c58752102b34 more output;
wenzelm
parents: 65791
diff changeset
   236
    val sorted_entries =
65762
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   237
      (for {
65792
c58752102b34 more output;
wenzelm
parents: 65791
diff changeset
   238
        (name, sessions) <- data_entries.toList
65847
ad35427dbe88 less restrictive filter: omit empty charts, but show latest timing;
wenzelm
parents: 65838
diff changeset
   239
        sorted_sessions <- proper_list(sessions.toList.map(_._2).sortBy(_.order))
65799
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
   240
      }
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
   241
      yield {
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
   242
        val hosts = get_hosts(name).toList.sorted
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
   243
        val stretch = data_stretch(name)
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
   244
        Data_Entry(name, hosts, stretch, sorted_sessions)
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
   245
      }).sortBy(_.name)
65792
c58752102b34 more output;
wenzelm
parents: 65791
diff changeset
   246
c58752102b34 more output;
wenzelm
parents: 65791
diff changeset
   247
    Data(date, sorted_entries)
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   248
  }
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   249
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   250
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   251
  /* present data */
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   252
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   253
  def present_data(data: Data,
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   254
    progress: Progress = No_Progress,
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   255
    target_dir: Path = default_target_dir,
65759
a2b041a36523 always show ml_timing -- in another chart;
wenzelm
parents: 65758
diff changeset
   256
    image_size: (Int, Int) = default_image_size)
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   257
  {
65791
wenzelm
parents: 65786
diff changeset
   258
    def clean_name(name: String): String =
wenzelm
parents: 65786
diff changeset
   259
      name.flatMap(c => if (c == ' ' || c == '/') "_" else if (c == ',') "" else c.toString)
wenzelm
parents: 65786
diff changeset
   260
65860
ce6be2e40d47 more output;
wenzelm
parents: 65859
diff changeset
   261
    def print_heap(x: Long): Option[String] =
65866
00e8b836d4db uniform heap_scale;
wenzelm
parents: 65865
diff changeset
   262
      if (x == 0L) None else Some(x.toString + " M")
65854
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
   263
65838
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   264
    HTML.write_document(target_dir, "index.html",
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   265
      List(HTML.title("Isabelle build status")),
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   266
      List(HTML.chapter("Isabelle build status"),
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   267
        HTML.par(
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   268
          List(HTML.description(
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   269
            List(HTML.text("status date:") -> HTML.text(data.date.toString))))),
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   270
        HTML.par(
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   271
          List(HTML.itemize(data.entries.map({ case data_entry =>
65893
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
   272
            List(
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
   273
              HTML.link(clean_name(data_entry.name) + "/index.html",
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
   274
                HTML.text(data_entry.name))) :::
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
   275
            (data_entry.failed_sessions match {
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
   276
              case Nil => Nil
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
   277
              case sessions =>
65940
9c7241798c3b show errors from build_log database;
wenzelm
parents: 65939
diff changeset
   278
                HTML.break :::
9c7241798c3b show errors from build_log database;
wenzelm
parents: 65939
diff changeset
   279
                List(HTML.span(HTML.text("Failed sessions:")) + HTML.error_message_class) :::
9c7241798c3b show errors from build_log database;
wenzelm
parents: 65939
diff changeset
   280
                List(HTML.itemize(sessions.map(s => s.head.present_errors(s.name))))
65893
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
   281
            })
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
   282
          }))))))
65786
wenzelm
parents: 65785
diff changeset
   283
65792
c58752102b34 more output;
wenzelm
parents: 65791
diff changeset
   284
    for (data_entry <- data.entries) {
c58752102b34 more output;
wenzelm
parents: 65791
diff changeset
   285
      val data_name = data_entry.name
c58752102b34 more output;
wenzelm
parents: 65791
diff changeset
   286
65865
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   287
      val (image_width, image_height) = image_size
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   288
      val image_width_stretch = (image_width * data_entry.stretch).toInt
65799
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
   289
65786
wenzelm
parents: 65785
diff changeset
   290
      progress.echo("output " + quote(data_name))
wenzelm
parents: 65785
diff changeset
   291
65764
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   292
      val dir = target_dir + Path.basic(clean_name(data_name))
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   293
      Isabelle_System.mkdirs(dir)
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   294
65764
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   295
      val session_plots =
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   296
        Par_List.map((session: Session) =>
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   297
          Isabelle_System.with_tmp_file(session.name, "data") { data_file =>
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   298
            Isabelle_System.with_tmp_file(session.name, "gnuplot") { gnuplot_file =>
63706
76c2f833abf4 present ML timing as well;
wenzelm
parents: 63703
diff changeset
   299
65865
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   300
              def plot_name(kind: String): String = session.name + "_" + kind + ".png"
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   301
65764
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   302
              File.write(data_file,
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   303
                cat_lines(
65893
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
   304
                  session.finished_entries.map(entry =>
65854
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
   305
                    List(entry.pull_date.unix_epoch,
65764
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   306
                      entry.timing.elapsed.minutes,
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   307
                      entry.timing.resources.minutes,
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   308
                      entry.ml_timing.elapsed.minutes,
65769
490b7c517000 plot heap size;
wenzelm
parents: 65766
diff changeset
   309
                      entry.ml_timing.resources.minutes,
65866
00e8b836d4db uniform heap_scale;
wenzelm
parents: 65865
diff changeset
   310
                      entry.maximum_heap,
00e8b836d4db uniform heap_scale;
wenzelm
parents: 65865
diff changeset
   311
                      entry.average_heap,
00e8b836d4db uniform heap_scale;
wenzelm
parents: 65865
diff changeset
   312
                      entry.stored_heap).mkString(" "))))
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   313
65764
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   314
              val max_time =
65893
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
   315
                ((0.0 /: session.finished_entries){ case (m, entry) =>
65764
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   316
                  m.max(entry.timing.elapsed.minutes).
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   317
                    max(entry.timing.resources.minutes).
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   318
                    max(entry.ml_timing.elapsed.minutes).
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   319
                    max(entry.ml_timing.resources.minutes) } max 0.1) * 1.1
65769
490b7c517000 plot heap size;
wenzelm
parents: 65766
diff changeset
   320
              val timing_range = "[0:" + max_time + "]"
65763
dbadcc3fbe33 tuned output;
wenzelm
parents: 65762
diff changeset
   321
65865
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   322
              def gnuplot(plot_name: String, plots: List[String], range: String): Image =
65764
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   323
              {
65865
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   324
                val image = Image(plot_name, image_width_stretch, image_height)
65764
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   325
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   326
                File.write(gnuplot_file, """
65865
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   327
set terminal png size """ + image.width + "," + image.height + """
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   328
set output """ + quote(File.standard_path(dir + image.path)) + """
65759
a2b041a36523 always show ml_timing -- in another chart;
wenzelm
parents: 65758
diff changeset
   329
set xdata time
a2b041a36523 always show ml_timing -- in another chart;
wenzelm
parents: 65758
diff changeset
   330
set timefmt "%s"
a2b041a36523 always show ml_timing -- in another chart;
wenzelm
parents: 65758
diff changeset
   331
set format x "%d-%b"
65762
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   332
set xlabel """ + quote(session.name) + """ noenhanced
65763
dbadcc3fbe33 tuned output;
wenzelm
parents: 65762
diff changeset
   333
set key left bottom
65769
490b7c517000 plot heap size;
wenzelm
parents: 65766
diff changeset
   334
plot [] """ + range + " " +
490b7c517000 plot heap size;
wenzelm
parents: 65766
diff changeset
   335
                plots.map(s => quote(data_file.implode) + " " + s).mkString(", ") + "\n")
65759
a2b041a36523 always show ml_timing -- in another chart;
wenzelm
parents: 65758
diff changeset
   336
65764
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   337
                val result =
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   338
                  Isabelle_System.bash("\"$ISABELLE_GNUPLOT\" " + File.bash_path(gnuplot_file))
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   339
                if (!result.ok)
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   340
                  result.error("Gnuplot failed for " + data_name + "/" + plot_name).check
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   341
65865
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   342
                image
65764
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   343
              }
65759
a2b041a36523 always show ml_timing -- in another chart;
wenzelm
parents: 65758
diff changeset
   344
65765
c67bb109cd7b cpu time is somewhat redundant for threads=1;
wenzelm
parents: 65764
diff changeset
   345
              val timing_plots =
65769
490b7c517000 plot heap size;
wenzelm
parents: 65766
diff changeset
   346
              {
490b7c517000 plot heap size;
wenzelm
parents: 65766
diff changeset
   347
                val plots1 =
490b7c517000 plot heap size;
wenzelm
parents: 65766
diff changeset
   348
                  List(
490b7c517000 plot heap size;
wenzelm
parents: 65766
diff changeset
   349
                    """ using 1:2 smooth sbezier title "elapsed time (smooth)" """,
490b7c517000 plot heap size;
wenzelm
parents: 65766
diff changeset
   350
                    """ using 1:2 smooth csplines title "elapsed time" """)
490b7c517000 plot heap size;
wenzelm
parents: 65766
diff changeset
   351
                val plots2 =
490b7c517000 plot heap size;
wenzelm
parents: 65766
diff changeset
   352
                  List(
490b7c517000 plot heap size;
wenzelm
parents: 65766
diff changeset
   353
                    """ using 1:3 smooth sbezier title "cpu time (smooth)" """,
490b7c517000 plot heap size;
wenzelm
parents: 65766
diff changeset
   354
                    """ using 1:3 smooth csplines title "cpu time" """)
490b7c517000 plot heap size;
wenzelm
parents: 65766
diff changeset
   355
                if (session.threads == 1) plots1 else plots1 ::: plots2
490b7c517000 plot heap size;
wenzelm
parents: 65766
diff changeset
   356
              }
65765
c67bb109cd7b cpu time is somewhat redundant for threads=1;
wenzelm
parents: 65764
diff changeset
   357
65764
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   358
              val ml_timing_plots =
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   359
                List(
65765
c67bb109cd7b cpu time is somewhat redundant for threads=1;
wenzelm
parents: 65764
diff changeset
   360
                  """ using 1:4 smooth sbezier title "ML elapsed time (smooth)" """,
c67bb109cd7b cpu time is somewhat redundant for threads=1;
wenzelm
parents: 65764
diff changeset
   361
                  """ using 1:4 smooth csplines title "ML elapsed time" """,
65764
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   362
                  """ using 1:5 smooth sbezier title "ML cpu time (smooth)" """,
65765
c67bb109cd7b cpu time is somewhat redundant for threads=1;
wenzelm
parents: 65764
diff changeset
   363
                  """ using 1:5 smooth csplines title "ML cpu time" """)
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   364
65769
490b7c517000 plot heap size;
wenzelm
parents: 65766
diff changeset
   365
              val heap_plots =
490b7c517000 plot heap size;
wenzelm
parents: 65766
diff changeset
   366
                List(
65859
95ddb6dea0d5 plot average heap size;
wenzelm
parents: 65857
diff changeset
   367
                  """ using 1:6 smooth sbezier title "maximum heap (smooth)" """,
95ddb6dea0d5 plot average heap size;
wenzelm
parents: 65857
diff changeset
   368
                  """ using 1:6 smooth csplines title "maximum heap" """,
95ddb6dea0d5 plot average heap size;
wenzelm
parents: 65857
diff changeset
   369
                  """ using 1:7 smooth sbezier title "average heap (smooth)" """,
95ddb6dea0d5 plot average heap size;
wenzelm
parents: 65857
diff changeset
   370
                  """ using 1:7 smooth csplines title "average heap" """,
65868
wenzelm
parents: 65867
diff changeset
   371
                  """ using 1:8 smooth sbezier title "stored heap (smooth)" """,
wenzelm
parents: 65867
diff changeset
   372
                  """ using 1:8 smooth csplines title "stored heap" """)
65769
490b7c517000 plot heap size;
wenzelm
parents: 65766
diff changeset
   373
65865
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   374
              def jfreechart(plot_name: String, fields: ML_Statistics.Fields): Image =
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   375
              {
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   376
                val image = Image(plot_name, image_width, image_height)
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   377
                val chart =
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   378
                  session.ml_statistics.chart(
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   379
                    fields._1 + ": " + session.ml_statistics.heading, fields._2)
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   380
                Graphics_File.write_chart_png(
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   381
                  (dir + image.path).file, chart, image.width, image.height)
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   382
                image
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   383
              }
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   384
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   385
              val images =
65847
ad35427dbe88 less restrictive filter: omit empty charts, but show latest timing;
wenzelm
parents: 65838
diff changeset
   386
                (if (session.check_timing)
ad35427dbe88 less restrictive filter: omit empty charts, but show latest timing;
wenzelm
parents: 65838
diff changeset
   387
                  List(
65865
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   388
                    gnuplot(plot_name("timing"), timing_plots, timing_range),
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   389
                    gnuplot(plot_name("ml_timing"), ml_timing_plots, timing_range))
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   390
                 else Nil) :::
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   391
                (if (session.check_heap)
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   392
                  List(gnuplot(plot_name("heap"), heap_plots, "[0:]"))
65847
ad35427dbe88 less restrictive filter: omit empty charts, but show latest timing;
wenzelm
parents: 65838
diff changeset
   393
                 else Nil) :::
65865
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   394
                (if (session.ml_statistics.content.nonEmpty)
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   395
                  List(jfreechart(plot_name("heap_chart"), ML_Statistics.heap_fields)) :::
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   396
                  (if (session.threads > 1)
65867
53613acb76e7 more charts;
wenzelm
parents: 65866
diff changeset
   397
                    List(
53613acb76e7 more charts;
wenzelm
parents: 65866
diff changeset
   398
                      jfreechart(plot_name("tasks_chart"), ML_Statistics.tasks_fields),
53613acb76e7 more charts;
wenzelm
parents: 65866
diff changeset
   399
                      jfreechart(plot_name("workers_chart"), ML_Statistics.workers_fields))
65865
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   400
                   else Nil)
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   401
                 else Nil)
65769
490b7c517000 plot heap size;
wenzelm
parents: 65766
diff changeset
   402
65865
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   403
              session.name -> images
65764
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   404
            }
65792
c58752102b34 more output;
wenzelm
parents: 65791
diff changeset
   405
          }, data_entry.sessions).toMap
65754
05c6a29c9132 clarified explicit Build_Status.Data operations;
wenzelm
parents: 65752
diff changeset
   406
65838
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   407
      HTML.write_document(dir, "index.html",
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   408
        List(HTML.title("Isabelle build status for " + data_name)),
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   409
        HTML.chapter("Isabelle build status for " + data_name) ::
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   410
        HTML.par(
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   411
          List(HTML.description(
65754
05c6a29c9132 clarified explicit Build_Status.Data operations;
wenzelm
parents: 65752
diff changeset
   412
            List(
65838
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   413
              HTML.text("status date:") -> HTML.text(data.date.toString),
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   414
              HTML.text("build host:") -> HTML.text(commas(data_entry.hosts)))))) ::
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   415
        HTML.par(
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   416
          List(HTML.itemize(
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   417
            data_entry.sessions.map(session =>
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   418
              HTML.link("#session_" + session.name, HTML.text(session.name)) ::
65863
94fe5e82d101 tuned signature;
wenzelm
parents: 65861
diff changeset
   419
              HTML.text(" (" + session.head.timing.message_resources + ")"))))) ::
65838
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   420
        data_entry.sessions.flatMap(session =>
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   421
          List(
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   422
            HTML.section(session.name) + HTML.id("session_" + session.name),
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   423
            HTML.par(
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   424
              HTML.description(
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   425
                List(
65863
94fe5e82d101 tuned signature;
wenzelm
parents: 65861
diff changeset
   426
                  HTML.text("timing:") -> HTML.text(session.head.timing.message_resources),
94fe5e82d101 tuned signature;
wenzelm
parents: 65861
diff changeset
   427
                  HTML.text("ML timing:") -> HTML.text(session.head.ml_timing.message_resources)) :::
94fe5e82d101 tuned signature;
wenzelm
parents: 65861
diff changeset
   428
                print_heap(session.head.maximum_heap).map(s =>
65860
ce6be2e40d47 more output;
wenzelm
parents: 65859
diff changeset
   429
                  HTML.text("maximum heap:") -> HTML.text(s)).toList :::
65863
94fe5e82d101 tuned signature;
wenzelm
parents: 65861
diff changeset
   430
                print_heap(session.head.average_heap).map(s =>
65860
ce6be2e40d47 more output;
wenzelm
parents: 65859
diff changeset
   431
                  HTML.text("average heap:") -> HTML.text(s)).toList :::
65866
00e8b836d4db uniform heap_scale;
wenzelm
parents: 65865
diff changeset
   432
                print_heap(session.head.stored_heap).map(s =>
00e8b836d4db uniform heap_scale;
wenzelm
parents: 65865
diff changeset
   433
                  HTML.text("stored heap:") -> HTML.text(s)).toList :::
65863
94fe5e82d101 tuned signature;
wenzelm
parents: 65861
diff changeset
   434
                proper_string(session.head.isabelle_version).map(s =>
65838
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   435
                  HTML.text("Isabelle version:") -> HTML.text(s)).toList :::
65863
94fe5e82d101 tuned signature;
wenzelm
parents: 65861
diff changeset
   436
                proper_string(session.head.afp_version).map(s =>
65838
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   437
                  HTML.text("AFP version:") -> HTML.text(s)).toList) ::
65865
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   438
              session_plots.getOrElse(session.name, Nil).map(image =>
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   439
                HTML.image(image.name) +
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   440
                  HTML.width(image.width / 2) +
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   441
                  HTML.height(image.height / 2))))))
63688
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   442
    }
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   443
  }
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   444
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   445
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   446
  /* Isabelle tool wrapper */
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   447
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   448
  val isabelle_tool =
65743
4847ca570454 clarified name;
wenzelm
parents: 65742
diff changeset
   449
    Isabelle_Tool("build_status", "present recent build status information from database", args =>
63688
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   450
    {
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   451
      var target_dir = default_target_dir
65854
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
   452
      var ml_statistics = false
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   453
      var only_sessions = Set.empty[String]
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   454
      var options = Options.init()
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   455
      var image_size = default_image_size
65750
7f5556f4b584 added option verbose for SQL source;
wenzelm
parents: 65747
diff changeset
   456
      var verbose = false
63688
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   457
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   458
      val getopts = Getopts("""
65743
4847ca570454 clarified name;
wenzelm
parents: 65742
diff changeset
   459
Usage: isabelle build_status [OPTIONS]
63688
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   460
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   461
  Options are:
65737
0729c09be90c tuned messages;
wenzelm
parents: 65736
diff changeset
   462
    -D DIR       target directory (default """ + default_target_dir + """)
65854
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
   463
    -M           include full ML statistics
63700
2a95d904672e clarified options and arguments;
wenzelm
parents: 63688
diff changeset
   464
    -S SESSIONS  only given SESSIONS (comma separated)
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   465
    -o OPTION    override Isabelle system OPTION (via NAME=VAL or NAME)
65737
0729c09be90c tuned messages;
wenzelm
parents: 65736
diff changeset
   466
    -s WxH       size of PNG image (default """ + image_size._1 + "x" + image_size._2 + """)
65750
7f5556f4b584 added option verbose for SQL source;
wenzelm
parents: 65747
diff changeset
   467
    -v           verbose
63688
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   468
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   469
  Present performance statistics from build log database, which is specified
65782
4935bac8a850 simplified default;
wenzelm
parents: 65773
diff changeset
   470
  via system options build_log_database_host, build_log_database_user,
4935bac8a850 simplified default;
wenzelm
parents: 65773
diff changeset
   471
  build_log_history etc.
63688
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   472
""",
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   473
        "D:" -> (arg => target_dir = Path.explode(arg)),
65854
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
   474
        "M" -> (_ => ml_statistics = true),
63700
2a95d904672e clarified options and arguments;
wenzelm
parents: 63688
diff changeset
   475
        "S:" -> (arg => only_sessions = space_explode(',', arg).toSet),
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   476
        "o:" -> (arg => options = options + arg),
63700
2a95d904672e clarified options and arguments;
wenzelm
parents: 63688
diff changeset
   477
        "s:" -> (arg =>
63805
c272680df665 clarified modules;
wenzelm
parents: 63708
diff changeset
   478
          space_explode('x', arg).map(Value.Int.parse(_)) match {
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   479
            case List(w, h) if w > 0 && h > 0 => image_size = (w, h)
63700
2a95d904672e clarified options and arguments;
wenzelm
parents: 63688
diff changeset
   480
            case _ => error("Error bad PNG image size: " + quote(arg))
65750
7f5556f4b584 added option verbose for SQL source;
wenzelm
parents: 65747
diff changeset
   481
          }),
7f5556f4b584 added option verbose for SQL source;
wenzelm
parents: 65747
diff changeset
   482
        "v" -> (_ => verbose = true))
63688
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   483
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   484
      val more_args = getopts(args)
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   485
      if (more_args.nonEmpty) getopts.usage()
63700
2a95d904672e clarified options and arguments;
wenzelm
parents: 63688
diff changeset
   486
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   487
      val progress = new Console_Progress
63688
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   488
65785
6107504371fb tuned signature;
wenzelm
parents: 65784
diff changeset
   489
      build_status(options, progress = progress, only_sessions = only_sessions, verbose = verbose,
65854
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
   490
        target_dir = target_dir, ml_statistics = ml_statistics, image_size = image_size)
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   491
64161
2b1128e95dfb explicit indication of Admin tools;
wenzelm
parents: 64106
diff changeset
   492
  }, admin = true)
63686
66f217416da7 statistics from session build output;
wenzelm
parents:
diff changeset
   493
}