src/Pure/Admin/build_status.scala
author wenzelm
Sun, 26 Feb 2023 20:19:01 +0100
changeset 77381 a86e346b20d8
parent 77375 324f5821a4a4
child 77510 f5d6cd98b16a
permissions -rw-r--r--
misc tuning and clarification: more uniform use of optional "sql" in SQL.Table.delete/select;
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
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74854
diff changeset
    10
object Build_Status {
65799
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
    11
  /* defaults */
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
    12
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
    13
  val default_target_dir = Path.explode("build_status")
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
    14
  val default_image_size = (800, 600)
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
    15
  val default_history = 30
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
    16
77133
536c033fb6eb removed somewhat pointless support for Jenkins log files: it has stopped working long ago;
wenzelm
parents: 77121
diff changeset
    17
  def default_profiles: List[Profile] = Isabelle_Cronjob.build_status_profiles
65799
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
    18
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
    19
65791
wenzelm
parents: 65786
diff changeset
    20
  /* data profiles */
wenzelm
parents: 65786
diff changeset
    21
66880
486f4af28db9 more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents: 66254
diff changeset
    22
  sealed case class Profile(
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74854
diff changeset
    23
    description: String,
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74854
diff changeset
    24
    history: Int = 0,
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74854
diff changeset
    25
    afp: Boolean = false,
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74854
diff changeset
    26
    bulky: Boolean = false,
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74854
diff changeset
    27
    sql: String
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74854
diff changeset
    28
  ) {
65799
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
    29
    def days(options: Options): Int = options.int("build_log_history") max 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 stretch(options: Options): Double =
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
    32
      (days(options) max default_history min (default_history * 5)).toDouble / default_history
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
    33
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74854
diff changeset
    34
    def select(
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74854
diff changeset
    35
      options: Options,
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74854
diff changeset
    36
      columns: List[SQL.Column],
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74854
diff changeset
    37
      only_sessions: Set[String]
75968
5a782ca6872b tuned signature: build_log db is specific to PostgreSQL;
wenzelm
parents: 75394
diff changeset
    38
    ): PostgreSQL.Source = {
77381
a86e346b20d8 misc tuning and clarification: more uniform use of optional "sql" in SQL.Table.delete/select;
wenzelm
parents: 77375
diff changeset
    39
      Build_Log.Data.universal_table.select(columns, distinct = true, sql =
a86e346b20d8 misc tuning and clarification: more uniform use of optional "sql" in SQL.Table.delete/select;
wenzelm
parents: 77375
diff changeset
    40
        "WHERE " +
66880
486f4af28db9 more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents: 66254
diff changeset
    41
          Build_Log.Data.pull_date(afp) + " > " + Build_Log.Data.recent_time(days(options)) +
486f4af28db9 more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents: 66254
diff changeset
    42
          " AND " +
77375
324f5821a4a4 clarified signature: more concise operations;
wenzelm
parents: 77368
diff changeset
    43
          Build_Log.Data.status.member(
65893
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
    44
            List(
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
    45
              Build_Log.Session_Status.finished.toString,
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
    46
              Build_Log.Session_Status.failed.toString)) +
77375
324f5821a4a4 clarified signature: more concise operations;
wenzelm
parents: 77368
diff changeset
    47
          if_proper(only_sessions, " AND " + Build_Log.Data.session_name.member(only_sessions)) +
66981
e76c6cb0d461 proper order for entries from multiple profiles, notably "AFP";
wenzelm
parents: 66980
diff changeset
    48
          " AND " + SQL.enclose(sql))
65791
wenzelm
parents: 65786
diff changeset
    49
    }
wenzelm
parents: 65786
diff changeset
    50
  }
wenzelm
parents: 65786
diff changeset
    51
wenzelm
parents: 65786
diff changeset
    52
65785
6107504371fb tuned signature;
wenzelm
parents: 65784
diff changeset
    53
  /* build status */
6107504371fb tuned signature;
wenzelm
parents: 65784
diff changeset
    54
6107504371fb tuned signature;
wenzelm
parents: 65784
diff changeset
    55
  def build_status(options: Options,
71726
a5fda30edae2 clarified signature: more uniform treatment of stopped/interrupted state;
wenzelm
parents: 70855
diff changeset
    56
    progress: Progress = new Progress,
65785
6107504371fb tuned signature;
wenzelm
parents: 65784
diff changeset
    57
    profiles: List[Profile] = default_profiles,
6107504371fb tuned signature;
wenzelm
parents: 65784
diff changeset
    58
    only_sessions: Set[String] = Set.empty,
6107504371fb tuned signature;
wenzelm
parents: 65784
diff changeset
    59
    verbose: Boolean = false,
6107504371fb tuned signature;
wenzelm
parents: 65784
diff changeset
    60
    target_dir: Path = default_target_dir,
65854
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
    61
    ml_statistics: Boolean = false,
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74854
diff changeset
    62
    image_size: (Int, Int) = default_image_size
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74854
diff changeset
    63
  ): Unit = {
67760
553d9ad7d679 more compact ML_Statistics, to make build_status work with less than 2GB heap;
wenzelm
parents: 67759
diff changeset
    64
    val ml_statistics_domain =
69822
8c587dd44f51 updated to polyml-5.8-20190220 (pre-release of Poly/ML 5.8);
wenzelm
parents: 69740
diff changeset
    65
      Iterator(ML_Statistics.heap_fields, ML_Statistics.program_fields, ML_Statistics.tasks_fields,
8c587dd44f51 updated to polyml-5.8-20190220 (pre-release of Poly/ML 5.8);
wenzelm
parents: 69740
diff changeset
    66
        ML_Statistics.workers_fields).flatMap(_._2).toSet
67760
553d9ad7d679 more compact ML_Statistics, to make build_status work with less than 2GB heap;
wenzelm
parents: 67759
diff changeset
    67
65785
6107504371fb tuned signature;
wenzelm
parents: 65784
diff changeset
    68
    val data =
6107504371fb tuned signature;
wenzelm
parents: 65784
diff changeset
    69
      read_data(options, progress = progress, profiles = profiles,
67760
553d9ad7d679 more compact ML_Statistics, to make build_status work with less than 2GB heap;
wenzelm
parents: 67759
diff changeset
    70
        only_sessions = only_sessions, verbose = verbose,
553d9ad7d679 more compact ML_Statistics, to make build_status work with less than 2GB heap;
wenzelm
parents: 67759
diff changeset
    71
        ml_statistics = ml_statistics, ml_statistics_domain = ml_statistics_domain)
65785
6107504371fb tuned signature;
wenzelm
parents: 65784
diff changeset
    72
6107504371fb tuned signature;
wenzelm
parents: 65784
diff changeset
    73
    present_data(data, progress = progress, target_dir = target_dir, image_size = image_size)
6107504371fb tuned signature;
wenzelm
parents: 65784
diff changeset
    74
  }
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    75
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    76
65791
wenzelm
parents: 65786
diff changeset
    77
  /* read data */
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    78
65792
c58752102b34 more output;
wenzelm
parents: 65791
diff changeset
    79
  sealed case class Data(date: Date, entries: List[Data_Entry])
65799
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
    80
  sealed case class Data_Entry(
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74854
diff changeset
    81
    name: String,
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74854
diff changeset
    82
    hosts: List[String],
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74854
diff changeset
    83
    stretch: Double,
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74854
diff changeset
    84
    sessions: List[Session]
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74854
diff changeset
    85
  ) {
65893
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
    86
    def failed_sessions: List[Session] =
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
    87
      sessions.filter(_.head.failed).sortBy(_.name)
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
    88
  }
65865
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
    89
  sealed case class Session(
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74854
diff changeset
    90
    name: String,
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74854
diff changeset
    91
    threads: Int,
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74854
diff changeset
    92
    entries: List[Entry],
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74854
diff changeset
    93
    ml_statistics: ML_Statistics,
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74854
diff changeset
    94
    ml_statistics_date: Long
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74854
diff changeset
    95
  ) {
73120
c3589f2dff31 more informative errors: simplify diagnosis of spurious failures reported by users;
wenzelm
parents: 73033
diff changeset
    96
    require(entries.nonEmpty, "no entries")
65795
c60b1a2c3abc clarified;
wenzelm
parents: 65794
diff changeset
    97
67739
e512938b853c clarified date for presentation vs. formal pull_date;
wenzelm
parents: 67738
diff changeset
    98
    lazy val sorted_entries: List[Entry] = entries.sortBy(entry => - entry.date)
66981
e76c6cb0d461 proper order for entries from multiple profiles, notably "AFP";
wenzelm
parents: 66980
diff changeset
    99
67003
49850a679c2c more robust sorted_entries;
wenzelm
parents: 67002
diff changeset
   100
    def head: Entry = sorted_entries.head
65863
94fe5e82d101 tuned signature;
wenzelm
parents: 65861
diff changeset
   101
    def order: Long = - head.timing.elapsed.ms
65860
ce6be2e40d47 more output;
wenzelm
parents: 65859
diff changeset
   102
67003
49850a679c2c more robust sorted_entries;
wenzelm
parents: 67002
diff changeset
   103
    def finished_entries: List[Entry] = sorted_entries.filter(_.finished)
67739
e512938b853c clarified date for presentation vs. formal pull_date;
wenzelm
parents: 67738
diff changeset
   104
    def finished_entries_size: Int = finished_entries.map(_.date).toSet.size
65893
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
   105
66254
6b5684ee07d9 proper check wrt. distinct entry dates;
wenzelm
parents: 65992
diff changeset
   106
    def check_timing: Boolean = finished_entries_size >= 3
65854
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
   107
    def check_heap: Boolean =
66254
6b5684ee07d9 proper check wrt. distinct entry dates;
wenzelm
parents: 65992
diff changeset
   108
      finished_entries_size >= 3 &&
65893
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
   109
      finished_entries.forall(entry =>
77121
ceee2a01322e clarified signature: more explicit types;
wenzelm
parents: 77117
diff changeset
   110
        entry.maximum_heap.is_proper ||
ceee2a01322e clarified signature: more explicit types;
wenzelm
parents: 77117
diff changeset
   111
        entry.average_heap.is_proper ||
ceee2a01322e clarified signature: more explicit types;
wenzelm
parents: 77117
diff changeset
   112
        entry.stored_heap.is_proper)
67738
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   113
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74854
diff changeset
   114
    def make_csv: CSV.File = {
67738
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   115
      val header =
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   116
        List("session_name",
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   117
          "chapter",
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   118
          "pull_date",
67739
e512938b853c clarified date for presentation vs. formal pull_date;
wenzelm
parents: 67738
diff changeset
   119
          "afp_pull_date",
67738
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   120
          "isabelle_version",
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   121
          "afp_version",
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   122
          "timing_elapsed",
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   123
          "timing_cpu",
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   124
          "timing_gc",
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   125
          "ml_timing_elapsed",
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   126
          "ml_timing_cpu",
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   127
          "ml_timing_gc",
69832
b614e3e4146a more memory fields;
wenzelm
parents: 69822
diff changeset
   128
          "maximum_code",
b614e3e4146a more memory fields;
wenzelm
parents: 69822
diff changeset
   129
          "average_code",
b614e3e4146a more memory fields;
wenzelm
parents: 69822
diff changeset
   130
          "maximum_stack",
b614e3e4146a more memory fields;
wenzelm
parents: 69822
diff changeset
   131
          "average_stack",
67738
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   132
          "maximum_heap",
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   133
          "average_heap",
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   134
          "stored_heap",
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   135
          "status")
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   136
      val date_format = Date.Format("uuuu-MM-dd HH:mm:ss")
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   137
      val records =
67749
08dc76bf6400 proper order;
wenzelm
parents: 67739
diff changeset
   138
        for (entry <- sorted_entries) yield {
67738
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   139
          CSV.Record(name,
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   140
            entry.chapter,
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   141
            date_format(entry.pull_date),
67739
e512938b853c clarified date for presentation vs. formal pull_date;
wenzelm
parents: 67738
diff changeset
   142
            entry.afp_pull_date match { case Some(date) => date_format(date) case None => "" },
67738
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   143
            entry.isabelle_version,
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   144
            entry.afp_version,
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   145
            entry.timing.elapsed.ms,
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   146
            entry.timing.cpu.ms,
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   147
            entry.timing.gc.ms,
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   148
            entry.ml_timing.elapsed.ms,
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   149
            entry.ml_timing.cpu.ms,
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   150
            entry.ml_timing.gc.ms,
69832
b614e3e4146a more memory fields;
wenzelm
parents: 69822
diff changeset
   151
            entry.maximum_code,
b614e3e4146a more memory fields;
wenzelm
parents: 69822
diff changeset
   152
            entry.average_code,
b614e3e4146a more memory fields;
wenzelm
parents: 69822
diff changeset
   153
            entry.maximum_stack,
b614e3e4146a more memory fields;
wenzelm
parents: 69822
diff changeset
   154
            entry.average_stack,
67738
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   155
            entry.maximum_heap,
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   156
            entry.average_heap,
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   157
            entry.stored_heap,
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   158
            entry.status)
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   159
        }
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   160
      CSV.File(name, header, records)
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   161
    }
65754
05c6a29c9132 clarified explicit Build_Status.Data operations;
wenzelm
parents: 65752
diff changeset
   162
  }
65854
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
   163
  sealed case class Entry(
66881
e7635ea96988 tuned output;
wenzelm
parents: 66880
diff changeset
   164
    chapter: String,
65854
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
   165
    pull_date: Date,
67739
e512938b853c clarified date for presentation vs. formal pull_date;
wenzelm
parents: 67738
diff changeset
   166
    afp_pull_date: Option[Date],
65854
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
   167
    isabelle_version: String,
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
   168
    afp_version: String,
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
   169
    timing: Timing,
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
   170
    ml_timing: Timing,
77121
ceee2a01322e clarified signature: more explicit types;
wenzelm
parents: 77117
diff changeset
   171
    maximum_code: Space,
ceee2a01322e clarified signature: more explicit types;
wenzelm
parents: 77117
diff changeset
   172
    average_code: Space,
ceee2a01322e clarified signature: more explicit types;
wenzelm
parents: 77117
diff changeset
   173
    maximum_stack: Space,
ceee2a01322e clarified signature: more explicit types;
wenzelm
parents: 77117
diff changeset
   174
    average_stack: Space,
ceee2a01322e clarified signature: more explicit types;
wenzelm
parents: 77117
diff changeset
   175
    maximum_heap: Space,
ceee2a01322e clarified signature: more explicit types;
wenzelm
parents: 77117
diff changeset
   176
    average_heap: Space,
ceee2a01322e clarified signature: more explicit types;
wenzelm
parents: 77117
diff changeset
   177
    stored_heap: Space,
65940
9c7241798c3b show errors from build_log database;
wenzelm
parents: 65939
diff changeset
   178
    status: Build_Log.Session_Status.Value,
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74854
diff changeset
   179
    errors: List[String]
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74854
diff changeset
   180
  ) {
67739
e512938b853c clarified date for presentation vs. formal pull_date;
wenzelm
parents: 67738
diff changeset
   181
    val date: Long = (afp_pull_date getOrElse pull_date).unix_epoch
e512938b853c clarified date for presentation vs. formal pull_date;
wenzelm
parents: 67738
diff changeset
   182
65893
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
   183
    def finished: Boolean = status == Build_Log.Session_Status.finished
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
   184
    def failed: Boolean = status == Build_Log.Session_Status.failed
65940
9c7241798c3b show errors from build_log database;
wenzelm
parents: 65939
diff changeset
   185
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74854
diff changeset
   186
    def present_errors(name: String): XML.Body = {
66881
e7635ea96988 tuned output;
wenzelm
parents: 66880
diff changeset
   187
      if (errors.isEmpty)
e7635ea96988 tuned output;
wenzelm
parents: 66880
diff changeset
   188
        HTML.text(name + print_version(isabelle_version, afp_version, chapter))
65940
9c7241798c3b show errors from build_log database;
wenzelm
parents: 65939
diff changeset
   189
      else {
65944
79e4d94aa9ad tuned signature;
wenzelm
parents: 65943
diff changeset
   190
        HTML.tooltip_errors(HTML.text(name), errors.map(s => HTML.text(Symbol.decode(s)))) ::
66881
e7635ea96988 tuned output;
wenzelm
parents: 66880
diff changeset
   191
          HTML.text(print_version(isabelle_version, afp_version, chapter))
65940
9c7241798c3b show errors from build_log database;
wenzelm
parents: 65939
diff changeset
   192
      }
66880
486f4af28db9 more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents: 66254
diff changeset
   193
    }
65893
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
   194
  }
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   195
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74854
diff changeset
   196
  sealed case class Image(name: String, width: Int, height: Int) {
65865
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   197
    def path: Path = Path.basic(name)
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   198
  }
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   199
66881
e7635ea96988 tuned output;
wenzelm
parents: 66880
diff changeset
   200
  def print_version(
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74854
diff changeset
   201
    isabelle_version: String,
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74854
diff changeset
   202
    afp_version: String = "",
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74854
diff changeset
   203
    chapter: String = AFP.chapter
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74854
diff changeset
   204
  ): String = {
66880
486f4af28db9 more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents: 66254
diff changeset
   205
    val body =
486f4af28db9 more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents: 66254
diff changeset
   206
      proper_string(isabelle_version).map("Isabelle/" + _).toList :::
70855
8a43ce639d85 tuned signature;
wenzelm
parents: 69894
diff changeset
   207
      (if (chapter == AFP.chapter) proper_string(afp_version).map("AFP/" + _) else None).toList
77368
wenzelm
parents: 77133
diff changeset
   208
    if_proper(body, body.mkString(" (", ", ", ")"))
66880
486f4af28db9 more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents: 66254
diff changeset
   209
  }
486f4af28db9 more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents: 66254
diff changeset
   210
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   211
  def read_data(options: Options,
71726
a5fda30edae2 clarified signature: more uniform treatment of stopped/interrupted state;
wenzelm
parents: 70855
diff changeset
   212
    progress: Progress = new Progress,
65785
6107504371fb tuned signature;
wenzelm
parents: 65784
diff changeset
   213
    profiles: List[Profile] = default_profiles,
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   214
    only_sessions: Set[String] = Set.empty,
65854
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
   215
    ml_statistics: Boolean = false,
74852
wenzelm
parents: 74776
diff changeset
   216
    ml_statistics_domain: String => Boolean = _ => true,
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74854
diff changeset
   217
    verbose: Boolean = false
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74854
diff changeset
   218
  ): Data = {
65754
05c6a29c9132 clarified explicit Build_Status.Data operations;
wenzelm
parents: 65752
diff changeset
   219
    val date = Date.now()
65792
c58752102b34 more output;
wenzelm
parents: 65791
diff changeset
   220
    var data_hosts = Map.empty[String, Set[String]]
65799
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
   221
    var data_stretch = Map.empty[String, Double]
65762
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   222
    var data_entries = Map.empty[String, Map[String, Session]]
63688
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   223
65792
c58752102b34 more output;
wenzelm
parents: 65791
diff changeset
   224
    def get_hosts(data_name: String): Set[String] =
c58752102b34 more output;
wenzelm
parents: 65791
diff changeset
   225
      data_hosts.getOrElse(data_name, Set.empty)
c58752102b34 more output;
wenzelm
parents: 65791
diff changeset
   226
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   227
    val store = Build_Log.store(options)
68018
3747fe57eb67 support for XZ.Cache;
wenzelm
parents: 67760
diff changeset
   228
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   229
    using(store.open_database()) { db =>
65764
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   230
      for (profile <- profiles.sortBy(_.description)) {
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   231
        progress.echo("input " + quote(profile.description))
65854
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
   232
66880
486f4af28db9 more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents: 66254
diff changeset
   233
        val afp = profile.afp
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   234
        val columns =
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   235
          List(
67739
e512938b853c clarified date for presentation vs. formal pull_date;
wenzelm
parents: 67738
diff changeset
   236
            Build_Log.Data.pull_date(afp = false),
e512938b853c clarified date for presentation vs. formal pull_date;
wenzelm
parents: 67738
diff changeset
   237
            Build_Log.Data.pull_date(afp = true),
65792
c58752102b34 more output;
wenzelm
parents: 65791
diff changeset
   238
            Build_Log.Prop.build_host,
65796
7d1c5150af70 more output;
wenzelm
parents: 65795
diff changeset
   239
            Build_Log.Prop.isabelle_version,
7d1c5150af70 more output;
wenzelm
parents: 65795
diff changeset
   240
            Build_Log.Prop.afp_version,
65752
ed7b5cd3a7f2 more uniform threads value, notably for Pure session;
wenzelm
parents: 65751
diff changeset
   241
            Build_Log.Settings.ISABELLE_BUILD_OPTIONS,
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   242
            Build_Log.Settings.ML_PLATFORM,
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   243
            Build_Log.Data.session_name,
66881
e7635ea96988 tuned output;
wenzelm
parents: 66880
diff changeset
   244
            Build_Log.Data.chapter,
66980
8947cf58cb86 tuned output;
wenzelm
parents: 66882
diff changeset
   245
            Build_Log.Data.groups,
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   246
            Build_Log.Data.threads,
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   247
            Build_Log.Data.timing_elapsed,
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   248
            Build_Log.Data.timing_cpu,
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   249
            Build_Log.Data.timing_gc,
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   250
            Build_Log.Data.ml_timing_elapsed,
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   251
            Build_Log.Data.ml_timing_cpu,
65769
490b7c517000 plot heap size;
wenzelm
parents: 65766
diff changeset
   252
            Build_Log.Data.ml_timing_gc,
65893
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
   253
            Build_Log.Data.heap_size,
65940
9c7241798c3b show errors from build_log database;
wenzelm
parents: 65939
diff changeset
   254
            Build_Log.Data.status,
9c7241798c3b show errors from build_log database;
wenzelm
parents: 65939
diff changeset
   255
            Build_Log.Data.errors) :::
65854
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
   256
          (if (ml_statistics) List(Build_Log.Data.ml_statistics) else Nil)
63700
2a95d904672e clarified options and arguments;
wenzelm
parents: 63688
diff changeset
   257
65752
ed7b5cd3a7f2 more uniform threads value, notably for Pure session;
wenzelm
parents: 65751
diff changeset
   258
        val Threads_Option = """threads\s*=\s*(\d+)""".r
ed7b5cd3a7f2 more uniform threads value, notably for Pure session;
wenzelm
parents: 65751
diff changeset
   259
65799
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
   260
        val sql = profile.select(options, columns, only_sessions)
71894
wenzelm
parents: 71726
diff changeset
   261
        progress.echo_if(verbose, sql)
65750
7f5556f4b584 added option verbose for SQL source;
wenzelm
parents: 65747
diff changeset
   262
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   263
        db.using_statement(sql) { stmt =>
65740
83388f09e9ab clarified signature;
wenzelm
parents: 65737
diff changeset
   264
          val res = stmt.execute_query()
83388f09e9ab clarified signature;
wenzelm
parents: 65737
diff changeset
   265
          while (res.next()) {
65766
2edb89630a80 more specific workaround (see also ed7b5cd3a7f2);
wenzelm
parents: 65765
diff changeset
   266
            val session_name = res.string(Build_Log.Data.session_name)
66881
e7635ea96988 tuned output;
wenzelm
parents: 66880
diff changeset
   267
            val chapter = res.string(Build_Log.Data.chapter)
66980
8947cf58cb86 tuned output;
wenzelm
parents: 66882
diff changeset
   268
            val groups = split_lines(res.string(Build_Log.Data.groups))
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74854
diff changeset
   269
            val threads = {
65764
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   270
              val threads1 =
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   271
                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
   272
                  case Threads_Option(Value.Int(i)) => i
65764
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   273
                  case _ => 1
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   274
                }
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   275
              val threads2 = res.get_int(Build_Log.Data.threads).getOrElse(1)
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   276
              threads1 max threads2
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   277
            }
65766
2edb89630a80 more specific workaround (see also ed7b5cd3a7f2);
wenzelm
parents: 65765
diff changeset
   278
            val ml_platform = res.string(Build_Log.Settings.ML_PLATFORM)
74776
251bf0f2d5bb proper detection of ARM platform variants;
wenzelm
parents: 73359
diff changeset
   279
            val ml_platform_64 =
251bf0f2d5bb proper detection of ARM platform variants;
wenzelm
parents: 73359
diff changeset
   280
              ml_platform.startsWith("x86_64-") || ml_platform.startsWith("arm64-")
65762
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   281
            val data_name =
65764
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   282
              profile.description +
74776
251bf0f2d5bb proper detection of ARM platform variants;
wenzelm
parents: 73359
diff changeset
   283
                (if (ml_platform_64) ", 64bit" else "") +
65764
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   284
                (if (threads == 1) "" else ", " + threads + " threads")
63703
ec095a532a2b provide index.html;
wenzelm
parents: 63702
diff changeset
   285
65799
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
   286
            res.get_string(Build_Log.Prop.build_host).foreach(host =>
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
   287
              data_hosts += (data_name -> (get_hosts(data_name) + host)))
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
   288
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
   289
            data_stretch += (data_name -> profile.stretch(options))
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
   290
65854
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
   291
            val isabelle_version = res.string(Build_Log.Prop.isabelle_version)
66880
486f4af28db9 more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents: 66254
diff changeset
   292
            val afp_version = res.string(Build_Log.Prop.afp_version)
65854
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
   293
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
   294
            val ml_stats =
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
   295
              ML_Statistics(
68018
3747fe57eb67 support for XZ.Cache;
wenzelm
parents: 67760
diff changeset
   296
                if (ml_statistics) {
73031
f93f0597f4fb clarified signature: absorb XZ.Cache into XML.Cache;
wenzelm
parents: 72763
diff changeset
   297
                  Properties.uncompress(res.bytes(Build_Log.Data.ml_statistics), cache = store.cache)
68018
3747fe57eb67 support for XZ.Cache;
wenzelm
parents: 67760
diff changeset
   298
                }
66881
e7635ea96988 tuned output;
wenzelm
parents: 66880
diff changeset
   299
                else Nil,
67760
553d9ad7d679 more compact ML_Statistics, to make build_status work with less than 2GB heap;
wenzelm
parents: 67759
diff changeset
   300
                domain = ml_statistics_domain,
66881
e7635ea96988 tuned output;
wenzelm
parents: 66880
diff changeset
   301
                heading = session_name + print_version(isabelle_version, afp_version, chapter))
65854
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
   302
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   303
            val entry =
65796
7d1c5150af70 more output;
wenzelm
parents: 65795
diff changeset
   304
              Entry(
66881
e7635ea96988 tuned output;
wenzelm
parents: 66880
diff changeset
   305
                chapter = chapter,
67739
e512938b853c clarified date for presentation vs. formal pull_date;
wenzelm
parents: 67738
diff changeset
   306
                pull_date = res.date(Build_Log.Data.pull_date(afp = false)),
e512938b853c clarified date for presentation vs. formal pull_date;
wenzelm
parents: 67738
diff changeset
   307
                afp_pull_date =
e512938b853c clarified date for presentation vs. formal pull_date;
wenzelm
parents: 67738
diff changeset
   308
                  if (afp) res.get_date(Build_Log.Data.pull_date(afp = true)) else None,
65854
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
   309
                isabelle_version = isabelle_version,
66880
486f4af28db9 more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents: 66254
diff changeset
   310
                afp_version = afp_version,
65796
7d1c5150af70 more output;
wenzelm
parents: 65795
diff changeset
   311
                timing =
7d1c5150af70 more output;
wenzelm
parents: 65795
diff changeset
   312
                  res.timing(
7d1c5150af70 more output;
wenzelm
parents: 65795
diff changeset
   313
                    Build_Log.Data.timing_elapsed,
7d1c5150af70 more output;
wenzelm
parents: 65795
diff changeset
   314
                    Build_Log.Data.timing_cpu,
7d1c5150af70 more output;
wenzelm
parents: 65795
diff changeset
   315
                    Build_Log.Data.timing_gc),
7d1c5150af70 more output;
wenzelm
parents: 65795
diff changeset
   316
                ml_timing =
7d1c5150af70 more output;
wenzelm
parents: 65795
diff changeset
   317
                  res.timing(
7d1c5150af70 more output;
wenzelm
parents: 65795
diff changeset
   318
                    Build_Log.Data.ml_timing_elapsed,
7d1c5150af70 more output;
wenzelm
parents: 65795
diff changeset
   319
                    Build_Log.Data.ml_timing_cpu,
7d1c5150af70 more output;
wenzelm
parents: 65795
diff changeset
   320
                    Build_Log.Data.ml_timing_gc),
77121
ceee2a01322e clarified signature: more explicit types;
wenzelm
parents: 77117
diff changeset
   321
                maximum_code = Space.B(ml_stats.maximum(ML_Statistics.CODE_SIZE)),
ceee2a01322e clarified signature: more explicit types;
wenzelm
parents: 77117
diff changeset
   322
                average_code = Space.B(ml_stats.average(ML_Statistics.CODE_SIZE)),
ceee2a01322e clarified signature: more explicit types;
wenzelm
parents: 77117
diff changeset
   323
                maximum_stack = Space.B(ml_stats.maximum(ML_Statistics.STACK_SIZE)),
ceee2a01322e clarified signature: more explicit types;
wenzelm
parents: 77117
diff changeset
   324
                average_stack = Space.B(ml_stats.average(ML_Statistics.STACK_SIZE)),
ceee2a01322e clarified signature: more explicit types;
wenzelm
parents: 77117
diff changeset
   325
                maximum_heap = Space.B(ml_stats.maximum(ML_Statistics.HEAP_SIZE)),
ceee2a01322e clarified signature: more explicit types;
wenzelm
parents: 77117
diff changeset
   326
                average_heap = Space.B(ml_stats.average(ML_Statistics.HEAP_SIZE)),
ceee2a01322e clarified signature: more explicit types;
wenzelm
parents: 77117
diff changeset
   327
                stored_heap = Space.bytes(res.long(Build_Log.Data.heap_size)),
65940
9c7241798c3b show errors from build_log database;
wenzelm
parents: 65939
diff changeset
   328
                status = Build_Log.Session_Status.withName(res.string(Build_Log.Data.status)),
68018
3747fe57eb67 support for XZ.Cache;
wenzelm
parents: 67760
diff changeset
   329
                errors =
73031
f93f0597f4fb clarified signature: absorb XZ.Cache into XML.Cache;
wenzelm
parents: 72763
diff changeset
   330
                  Build_Log.uncompress_errors(
73033
d2690444c00a clarified caching;
wenzelm
parents: 73031
diff changeset
   331
                    res.bytes(Build_Log.Data.errors), cache = store.cache))
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   332
65762
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   333
            val sessions = data_entries.getOrElse(data_name, Map.empty)
67759
56eba30e7b99 retain latest ml_stats (amending e76c6cb0d461);
wenzelm
parents: 67749
diff changeset
   334
            val session =
56eba30e7b99 retain latest ml_stats (amending e76c6cb0d461);
wenzelm
parents: 67749
diff changeset
   335
              sessions.get(session_name) match {
56eba30e7b99 retain latest ml_stats (amending e76c6cb0d461);
wenzelm
parents: 67749
diff changeset
   336
                case None =>
56eba30e7b99 retain latest ml_stats (amending e76c6cb0d461);
wenzelm
parents: 67749
diff changeset
   337
                  Session(session_name, threads, List(entry), ml_stats, entry.date)
56eba30e7b99 retain latest ml_stats (amending e76c6cb0d461);
wenzelm
parents: 67749
diff changeset
   338
                case Some(old) =>
56eba30e7b99 retain latest ml_stats (amending e76c6cb0d461);
wenzelm
parents: 67749
diff changeset
   339
                  val (ml_stats1, ml_stats1_date) =
56eba30e7b99 retain latest ml_stats (amending e76c6cb0d461);
wenzelm
parents: 67749
diff changeset
   340
                    if (entry.date > old.ml_statistics_date) (ml_stats, entry.date)
56eba30e7b99 retain latest ml_stats (amending e76c6cb0d461);
wenzelm
parents: 67749
diff changeset
   341
                    else (old.ml_statistics, old.ml_statistics_date)
56eba30e7b99 retain latest ml_stats (amending e76c6cb0d461);
wenzelm
parents: 67749
diff changeset
   342
                  Session(session_name, threads, entry :: old.entries, ml_stats1, ml_stats1_date)
56eba30e7b99 retain latest ml_stats (amending e76c6cb0d461);
wenzelm
parents: 67749
diff changeset
   343
              }
66882
2d98b0141d89 clarified output;
wenzelm
parents: 66881
diff changeset
   344
70855
8a43ce639d85 tuned signature;
wenzelm
parents: 69894
diff changeset
   345
            if ((!afp || chapter == AFP.chapter) &&
69740
18d383f41477 proper operation in weakly-typed Scala (amending 06153e2e0cdb);
wenzelm
parents: 69734
diff changeset
   346
                (!profile.bulky || groups.exists(AFP.groups_bulky.toSet))) {
66882
2d98b0141d89 clarified output;
wenzelm
parents: 66881
diff changeset
   347
              data_entries += (data_name -> (sessions + (session_name -> session)))
2d98b0141d89 clarified output;
wenzelm
parents: 66881
diff changeset
   348
            }
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   349
          }
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   350
        }
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   351
      }
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   352
    }
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   353
65792
c58752102b34 more output;
wenzelm
parents: 65791
diff changeset
   354
    val sorted_entries =
65762
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   355
      (for {
65792
c58752102b34 more output;
wenzelm
parents: 65791
diff changeset
   356
        (name, sessions) <- data_entries.toList
67003
49850a679c2c more robust sorted_entries;
wenzelm
parents: 67002
diff changeset
   357
        sorted_sessions <- proper_list(sessions.toList.map(_._2).sortBy(_.order))
65799
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
   358
      }
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
   359
      yield {
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
   360
        val hosts = get_hosts(name).toList.sorted
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
   361
        val stretch = data_stretch(name)
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
   362
        Data_Entry(name, hosts, stretch, sorted_sessions)
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
   363
      }).sortBy(_.name)
65792
c58752102b34 more output;
wenzelm
parents: 65791
diff changeset
   364
c58752102b34 more output;
wenzelm
parents: 65791
diff changeset
   365
    Data(date, sorted_entries)
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   366
  }
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   367
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   368
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   369
  /* present data */
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   370
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   371
  def present_data(data: Data,
71726
a5fda30edae2 clarified signature: more uniform treatment of stopped/interrupted state;
wenzelm
parents: 70855
diff changeset
   372
    progress: Progress = new Progress,
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   373
    target_dir: Path = default_target_dir,
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74854
diff changeset
   374
    image_size: (Int, Int) = default_image_size
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74854
diff changeset
   375
  ): Unit = {
65791
wenzelm
parents: 65786
diff changeset
   376
    def clean_name(name: String): String =
wenzelm
parents: 65786
diff changeset
   377
      name.flatMap(c => if (c == ' ' || c == '/') "_" else if (c == ',') "" else c.toString)
wenzelm
parents: 65786
diff changeset
   378
65838
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   379
    HTML.write_document(target_dir, "index.html",
65945
35652d0834f4 tuned signature;
wenzelm
parents: 65944
diff changeset
   380
      List(HTML.title("Isabelle build status")),
65838
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   381
      List(HTML.chapter("Isabelle build status"),
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   382
        HTML.par(
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   383
          List(HTML.description(
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   384
            List(HTML.text("status date:") -> HTML.text(data.date.toString))))),
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   385
        HTML.par(
74852
wenzelm
parents: 74776
diff changeset
   386
          List(HTML.itemize(data.entries.map(data_entry =>
65893
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
   387
            List(
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
   388
              HTML.link(clean_name(data_entry.name) + "/index.html",
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
   389
                HTML.text(data_entry.name))) :::
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
   390
            (data_entry.failed_sessions match {
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
   391
              case Nil => Nil
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
   392
              case sessions =>
65940
9c7241798c3b show errors from build_log database;
wenzelm
parents: 65939
diff changeset
   393
                HTML.break :::
65992
50daca61efd6 tuned signature;
wenzelm
parents: 65946
diff changeset
   394
                List(HTML.span(HTML.error_message, HTML.text("Failed sessions:"))) :::
65940
9c7241798c3b show errors from build_log database;
wenzelm
parents: 65939
diff changeset
   395
                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
   396
            })
74852
wenzelm
parents: 74776
diff changeset
   397
          ))))))
65786
wenzelm
parents: 65785
diff changeset
   398
65792
c58752102b34 more output;
wenzelm
parents: 65791
diff changeset
   399
    for (data_entry <- data.entries) {
c58752102b34 more output;
wenzelm
parents: 65791
diff changeset
   400
      val data_name = data_entry.name
c58752102b34 more output;
wenzelm
parents: 65791
diff changeset
   401
65865
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   402
      val (image_width, image_height) = image_size
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   403
      val image_width_stretch = (image_width * data_entry.stretch).toInt
65799
ed705d6a6a63 stretch image according to history length;
wenzelm
parents: 65798
diff changeset
   404
65786
wenzelm
parents: 65785
diff changeset
   405
      progress.echo("output " + quote(data_name))
wenzelm
parents: 65785
diff changeset
   406
72376
04bce3478688 clarified signature;
wenzelm
parents: 72375
diff changeset
   407
      val dir = Isabelle_System.make_directory(target_dir + Path.basic(clean_name(data_name)))
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   408
67738
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   409
      val data_files =
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   410
        (for (session <- data_entry.sessions) yield {
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   411
          val csv_file = session.make_csv
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   412
          csv_file.write(dir)
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   413
          session.name -> csv_file
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   414
        }).toMap
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   415
65764
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   416
      val session_plots =
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   417
        Par_List.map((session: Session) =>
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   418
          Isabelle_System.with_tmp_file(session.name, "data") { data_file =>
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   419
            Isabelle_System.with_tmp_file(session.name, "gnuplot") { gnuplot_file =>
63706
76c2f833abf4 present ML timing as well;
wenzelm
parents: 63703
diff changeset
   420
65865
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   421
              def plot_name(kind: String): String = session.name + "_" + kind + ".png"
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   422
65764
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   423
              File.write(data_file,
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   424
                cat_lines(
65893
20656a4709d6 show failed sessions on main page;
wenzelm
parents: 65868
diff changeset
   425
                  session.finished_entries.map(entry =>
73343
d0378baf7d06 tuned --- avoid deprecated conversions between certain number type;
wenzelm
parents: 73340
diff changeset
   426
                    List(entry.date.toString,
d0378baf7d06 tuned --- avoid deprecated conversions between certain number type;
wenzelm
parents: 73340
diff changeset
   427
                      entry.timing.elapsed.minutes.toString,
d0378baf7d06 tuned --- avoid deprecated conversions between certain number type;
wenzelm
parents: 73340
diff changeset
   428
                      entry.timing.resources.minutes.toString,
d0378baf7d06 tuned --- avoid deprecated conversions between certain number type;
wenzelm
parents: 73340
diff changeset
   429
                      entry.ml_timing.elapsed.minutes.toString,
d0378baf7d06 tuned --- avoid deprecated conversions between certain number type;
wenzelm
parents: 73340
diff changeset
   430
                      entry.ml_timing.resources.minutes.toString,
77121
ceee2a01322e clarified signature: more explicit types;
wenzelm
parents: 77117
diff changeset
   431
                      entry.maximum_code.MiB.toString,
ceee2a01322e clarified signature: more explicit types;
wenzelm
parents: 77117
diff changeset
   432
                      entry.average_code.MiB.toString,
ceee2a01322e clarified signature: more explicit types;
wenzelm
parents: 77117
diff changeset
   433
                      entry.maximum_stack.MiB.toString,
ceee2a01322e clarified signature: more explicit types;
wenzelm
parents: 77117
diff changeset
   434
                      entry.average_stack.MiB.toString,
ceee2a01322e clarified signature: more explicit types;
wenzelm
parents: 77117
diff changeset
   435
                      entry.maximum_heap.MiB.toString,
ceee2a01322e clarified signature: more explicit types;
wenzelm
parents: 77117
diff changeset
   436
                      entry.average_heap.MiB.toString,
ceee2a01322e clarified signature: more explicit types;
wenzelm
parents: 77117
diff changeset
   437
                      entry.stored_heap.MiB.toString).mkString(" "))))
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   438
65764
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   439
              val max_time =
73359
d8a0e996614b tuned --- fewer warnings;
wenzelm
parents: 73343
diff changeset
   440
                (session.finished_entries.foldLeft(0.0) {
d8a0e996614b tuned --- fewer warnings;
wenzelm
parents: 73343
diff changeset
   441
                  case (m, entry) =>
d8a0e996614b tuned --- fewer warnings;
wenzelm
parents: 73343
diff changeset
   442
                    m.max(entry.timing.elapsed.minutes).
d8a0e996614b tuned --- fewer warnings;
wenzelm
parents: 73343
diff changeset
   443
                      max(entry.timing.resources.minutes).
d8a0e996614b tuned --- fewer warnings;
wenzelm
parents: 73343
diff changeset
   444
                      max(entry.ml_timing.elapsed.minutes).
d8a0e996614b tuned --- fewer warnings;
wenzelm
parents: 73343
diff changeset
   445
                      max(entry.ml_timing.resources.minutes)
d8a0e996614b tuned --- fewer warnings;
wenzelm
parents: 73343
diff changeset
   446
                } max 0.1) * 1.1
65769
490b7c517000 plot heap size;
wenzelm
parents: 65766
diff changeset
   447
              val timing_range = "[0:" + max_time + "]"
65763
dbadcc3fbe33 tuned output;
wenzelm
parents: 65762
diff changeset
   448
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74854
diff changeset
   449
              def gnuplot(plot_name: String, plots: List[String], range: String): Image = {
65865
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   450
                val image = Image(plot_name, image_width_stretch, image_height)
65764
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   451
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   452
                File.write(gnuplot_file, """
65865
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   453
set terminal png size """ + image.width + "," + image.height + """
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   454
set output """ + quote(File.standard_path(dir + image.path)) + """
65759
a2b041a36523 always show ml_timing -- in another chart;
wenzelm
parents: 65758
diff changeset
   455
set xdata time
a2b041a36523 always show ml_timing -- in another chart;
wenzelm
parents: 65758
diff changeset
   456
set timefmt "%s"
a2b041a36523 always show ml_timing -- in another chart;
wenzelm
parents: 65758
diff changeset
   457
set format x "%d-%b"
65762
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   458
set xlabel """ + quote(session.name) + """ noenhanced
65763
dbadcc3fbe33 tuned output;
wenzelm
parents: 65762
diff changeset
   459
set key left bottom
65769
490b7c517000 plot heap size;
wenzelm
parents: 65766
diff changeset
   460
plot [] """ + range + " " +
490b7c517000 plot heap size;
wenzelm
parents: 65766
diff changeset
   461
                plots.map(s => quote(data_file.implode) + " " + s).mkString(", ") + "\n")
65759
a2b041a36523 always show ml_timing -- in another chart;
wenzelm
parents: 65758
diff changeset
   462
65764
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   463
                val result =
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   464
                  Isabelle_System.bash("\"$ISABELLE_GNUPLOT\" " + File.bash_path(gnuplot_file))
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   465
                if (!result.ok)
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   466
                  result.error("Gnuplot failed for " + data_name + "/" + plot_name).check
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   467
65865
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   468
                image
65764
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   469
              }
65759
a2b041a36523 always show ml_timing -- in another chart;
wenzelm
parents: 65758
diff changeset
   470
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74854
diff changeset
   471
              val timing_plots = {
65769
490b7c517000 plot heap size;
wenzelm
parents: 65766
diff changeset
   472
                val plots1 =
490b7c517000 plot heap size;
wenzelm
parents: 65766
diff changeset
   473
                  List(
490b7c517000 plot heap size;
wenzelm
parents: 65766
diff changeset
   474
                    """ using 1:2 smooth sbezier title "elapsed time (smooth)" """,
490b7c517000 plot heap size;
wenzelm
parents: 65766
diff changeset
   475
                    """ using 1:2 smooth csplines title "elapsed time" """)
490b7c517000 plot heap size;
wenzelm
parents: 65766
diff changeset
   476
                val plots2 =
490b7c517000 plot heap size;
wenzelm
parents: 65766
diff changeset
   477
                  List(
490b7c517000 plot heap size;
wenzelm
parents: 65766
diff changeset
   478
                    """ using 1:3 smooth sbezier title "cpu time (smooth)" """,
490b7c517000 plot heap size;
wenzelm
parents: 65766
diff changeset
   479
                    """ using 1:3 smooth csplines title "cpu time" """)
490b7c517000 plot heap size;
wenzelm
parents: 65766
diff changeset
   480
                if (session.threads == 1) plots1 else plots1 ::: plots2
490b7c517000 plot heap size;
wenzelm
parents: 65766
diff changeset
   481
              }
65765
c67bb109cd7b cpu time is somewhat redundant for threads=1;
wenzelm
parents: 65764
diff changeset
   482
65764
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   483
              val ml_timing_plots =
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   484
                List(
65765
c67bb109cd7b cpu time is somewhat redundant for threads=1;
wenzelm
parents: 65764
diff changeset
   485
                  """ using 1:4 smooth sbezier title "ML elapsed time (smooth)" """,
c67bb109cd7b cpu time is somewhat redundant for threads=1;
wenzelm
parents: 65764
diff changeset
   486
                  """ using 1:4 smooth csplines title "ML elapsed time" """,
65764
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   487
                  """ 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
   488
                  """ using 1:5 smooth csplines title "ML cpu time" """)
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   489
65769
490b7c517000 plot heap size;
wenzelm
parents: 65766
diff changeset
   490
              val heap_plots =
490b7c517000 plot heap size;
wenzelm
parents: 65766
diff changeset
   491
                List(
69894
2eade8651b93 proper data columns for plots;
wenzelm
parents: 69833
diff changeset
   492
                  """ using 1:10 smooth sbezier title "heap maximum (smooth)" """,
2eade8651b93 proper data columns for plots;
wenzelm
parents: 69833
diff changeset
   493
                  """ using 1:10 smooth csplines title "heap maximum" """,
2eade8651b93 proper data columns for plots;
wenzelm
parents: 69833
diff changeset
   494
                  """ using 1:11 smooth sbezier title "heap average (smooth)" """,
2eade8651b93 proper data columns for plots;
wenzelm
parents: 69833
diff changeset
   495
                  """ using 1:11 smooth csplines title "heap average" """,
2eade8651b93 proper data columns for plots;
wenzelm
parents: 69833
diff changeset
   496
                  """ using 1:12 smooth sbezier title "heap stored (smooth)" """,
2eade8651b93 proper data columns for plots;
wenzelm
parents: 69833
diff changeset
   497
                  """ using 1:12 smooth csplines title "heap stored" """)
65769
490b7c517000 plot heap size;
wenzelm
parents: 65766
diff changeset
   498
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74854
diff changeset
   499
              def jfreechart(plot_name: String, fields: ML_Statistics.Fields): Image = {
65865
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   500
                val image = Image(plot_name, image_width, image_height)
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   501
                val chart =
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   502
                  session.ml_statistics.chart(
77117
9a22256b0a27 clarified signature: more explicit types;
wenzelm
parents: 75968
diff changeset
   503
                    fields.title + ": " + session.ml_statistics.heading, fields.names)
65865
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   504
                Graphics_File.write_chart_png(
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   505
                  (dir + image.path).file, chart, image.width, image.height)
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   506
                image
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   507
              }
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   508
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   509
              val images =
65847
ad35427dbe88 less restrictive filter: omit empty charts, but show latest timing;
wenzelm
parents: 65838
diff changeset
   510
                (if (session.check_timing)
ad35427dbe88 less restrictive filter: omit empty charts, but show latest timing;
wenzelm
parents: 65838
diff changeset
   511
                  List(
65865
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   512
                    gnuplot(plot_name("timing"), timing_plots, timing_range),
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   513
                    gnuplot(plot_name("ml_timing"), ml_timing_plots, timing_range))
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   514
                 else Nil) :::
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   515
                (if (session.check_heap)
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   516
                  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
   517
                 else Nil) :::
65865
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   518
                (if (session.ml_statistics.content.nonEmpty)
69822
8c587dd44f51 updated to polyml-5.8-20190220 (pre-release of Poly/ML 5.8);
wenzelm
parents: 69740
diff changeset
   519
                  List(jfreechart(plot_name("heap_chart"), ML_Statistics.heap_fields),
8c587dd44f51 updated to polyml-5.8-20190220 (pre-release of Poly/ML 5.8);
wenzelm
parents: 69740
diff changeset
   520
                    jfreechart(plot_name("program_chart"), ML_Statistics.program_fields)) :::
65865
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   521
                  (if (session.threads > 1)
65867
53613acb76e7 more charts;
wenzelm
parents: 65866
diff changeset
   522
                    List(
53613acb76e7 more charts;
wenzelm
parents: 65866
diff changeset
   523
                      jfreechart(plot_name("tasks_chart"), ML_Statistics.tasks_fields),
53613acb76e7 more charts;
wenzelm
parents: 65866
diff changeset
   524
                      jfreechart(plot_name("workers_chart"), ML_Statistics.workers_fields))
65865
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   525
                   else Nil)
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   526
                 else Nil)
65769
490b7c517000 plot heap size;
wenzelm
parents: 65766
diff changeset
   527
65865
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   528
              session.name -> images
65764
1af6d544c2a3 clarified description vs. file name;
wenzelm
parents: 65763
diff changeset
   529
            }
65792
c58752102b34 more output;
wenzelm
parents: 65791
diff changeset
   530
          }, data_entry.sessions).toMap
65754
05c6a29c9132 clarified explicit Build_Status.Data operations;
wenzelm
parents: 65752
diff changeset
   531
65838
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   532
      HTML.write_document(dir, "index.html",
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   533
        List(HTML.title("Isabelle build status for " + data_name)),
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   534
        HTML.chapter("Isabelle build status for " + data_name) ::
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   535
        HTML.par(
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   536
          List(HTML.description(
65754
05c6a29c9132 clarified explicit Build_Status.Data operations;
wenzelm
parents: 65752
diff changeset
   537
            List(
65838
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   538
              HTML.text("status date:") -> HTML.text(data.date.toString),
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   539
              HTML.text("build host:") -> HTML.text(commas(data_entry.hosts)))))) ::
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   540
        HTML.par(
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   541
          List(HTML.itemize(
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   542
            data_entry.sessions.map(session =>
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   543
              HTML.link("#session_" + session.name, HTML.text(session.name)) ::
65863
94fe5e82d101 tuned signature;
wenzelm
parents: 65861
diff changeset
   544
              HTML.text(" (" + session.head.timing.message_resources + ")"))))) ::
65838
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   545
        data_entry.sessions.flatMap(session =>
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   546
          List(
65992
50daca61efd6 tuned signature;
wenzelm
parents: 65946
diff changeset
   547
            HTML.section(HTML.id("session_" + session.name), session.name),
65838
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   548
            HTML.par(
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   549
              HTML.description(
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   550
                List(
67738
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   551
                  HTML.text("data:") ->
1bbe618c4b24 reveal raw data in CSV format;
wenzelm
parents: 67003
diff changeset
   552
                    List(HTML.link(data_files(session.name).file_name, HTML.text("CSV"))),
65863
94fe5e82d101 tuned signature;
wenzelm
parents: 65861
diff changeset
   553
                  HTML.text("timing:") -> HTML.text(session.head.timing.message_resources),
94fe5e82d101 tuned signature;
wenzelm
parents: 65861
diff changeset
   554
                  HTML.text("ML timing:") -> HTML.text(session.head.ml_timing.message_resources)) :::
77121
ceee2a01322e clarified signature: more explicit types;
wenzelm
parents: 77117
diff changeset
   555
                session.head.maximum_code.print_relevant.map(s =>
69833
c3500cec8290 tuned output;
wenzelm
parents: 69832
diff changeset
   556
                  HTML.text("code maximum:") -> HTML.text(s)).toList :::
77121
ceee2a01322e clarified signature: more explicit types;
wenzelm
parents: 77117
diff changeset
   557
                session.head.average_code.print_relevant.map(s =>
69833
c3500cec8290 tuned output;
wenzelm
parents: 69832
diff changeset
   558
                  HTML.text("code average:") -> HTML.text(s)).toList :::
77121
ceee2a01322e clarified signature: more explicit types;
wenzelm
parents: 77117
diff changeset
   559
                session.head.maximum_stack.print_relevant.map(s =>
69833
c3500cec8290 tuned output;
wenzelm
parents: 69832
diff changeset
   560
                  HTML.text("stack maximum:") -> HTML.text(s)).toList :::
77121
ceee2a01322e clarified signature: more explicit types;
wenzelm
parents: 77117
diff changeset
   561
                session.head.average_stack.print_relevant.map(s =>
69833
c3500cec8290 tuned output;
wenzelm
parents: 69832
diff changeset
   562
                  HTML.text("stack average:") -> HTML.text(s)).toList :::
77121
ceee2a01322e clarified signature: more explicit types;
wenzelm
parents: 77117
diff changeset
   563
                session.head.maximum_heap.print_relevant.map(s =>
69833
c3500cec8290 tuned output;
wenzelm
parents: 69832
diff changeset
   564
                  HTML.text("heap maximum:") -> HTML.text(s)).toList :::
77121
ceee2a01322e clarified signature: more explicit types;
wenzelm
parents: 77117
diff changeset
   565
                session.head.average_heap.print_relevant.map(s =>
69833
c3500cec8290 tuned output;
wenzelm
parents: 69832
diff changeset
   566
                  HTML.text("heap average:") -> HTML.text(s)).toList :::
77121
ceee2a01322e clarified signature: more explicit types;
wenzelm
parents: 77117
diff changeset
   567
                session.head.stored_heap.print_relevant.map(s =>
69833
c3500cec8290 tuned output;
wenzelm
parents: 69832
diff changeset
   568
                  HTML.text("heap stored:") -> HTML.text(s)).toList :::
65863
94fe5e82d101 tuned signature;
wenzelm
parents: 65861
diff changeset
   569
                proper_string(session.head.isabelle_version).map(s =>
65838
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   570
                  HTML.text("Isabelle version:") -> HTML.text(s)).toList :::
65863
94fe5e82d101 tuned signature;
wenzelm
parents: 65861
diff changeset
   571
                proper_string(session.head.afp_version).map(s =>
65838
30c2d78b5d38 tuned signature;
wenzelm
parents: 65836
diff changeset
   572
                  HTML.text("AFP version:") -> HTML.text(s)).toList) ::
65865
177b90f33f40 more plots from ml_statistics;
wenzelm
parents: 65863
diff changeset
   573
              session_plots.getOrElse(session.name, Nil).map(image =>
65946
5dd3974cf0bc tuned signature;
wenzelm
parents: 65945
diff changeset
   574
                HTML.size(image.width / 2, image.height / 2)(HTML.image(image.name)))))))
63688
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   575
    }
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   576
  }
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   577
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   578
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   579
  /* Isabelle tool wrapper */
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   580
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   581
  val isabelle_tool =
72763
3cc73d00553c added document antiquotation @{tool};
wenzelm
parents: 72376
diff changeset
   582
    Isabelle_Tool("build_status", "present recent build status information from database",
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   583
      Scala_Project.here,
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   584
      { args =>
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   585
        var target_dir = default_target_dir
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   586
        var ml_statistics = false
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   587
        var only_sessions = Set.empty[String]
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   588
        var options = Options.init()
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   589
        var image_size = default_image_size
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   590
        var verbose = false
63688
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   591
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   592
        val getopts = Getopts("""
65743
4847ca570454 clarified name;
wenzelm
parents: 65742
diff changeset
   593
Usage: isabelle build_status [OPTIONS]
63688
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   594
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   595
  Options are:
65737
0729c09be90c tuned messages;
wenzelm
parents: 65736
diff changeset
   596
    -D DIR       target directory (default """ + default_target_dir + """)
65854
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65849
diff changeset
   597
    -M           include full ML statistics
63700
2a95d904672e clarified options and arguments;
wenzelm
parents: 63688
diff changeset
   598
    -S SESSIONS  only given SESSIONS (comma separated)
67002
e8d64340d58b more convenient build_log_history;
wenzelm
parents: 66981
diff changeset
   599
    -l DAYS      length of relevant history (default """ + options.int("build_log_history") + """)
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   600
    -o OPTION    override Isabelle system OPTION (via NAME=VAL or NAME)
65737
0729c09be90c tuned messages;
wenzelm
parents: 65736
diff changeset
   601
    -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
   602
    -v           verbose
63688
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   603
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   604
  Present performance statistics from build log database, which is specified
65782
4935bac8a850 simplified default;
wenzelm
parents: 65773
diff changeset
   605
  via system options build_log_database_host, build_log_database_user,
4935bac8a850 simplified default;
wenzelm
parents: 65773
diff changeset
   606
  build_log_history etc.
63688
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   607
""",
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   608
          "D:" -> (arg => target_dir = Path.explode(arg)),
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   609
          "M" -> (_ => ml_statistics = true),
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   610
          "S:" -> (arg => only_sessions = space_explode(',', arg).toSet),
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   611
          "l:" -> (arg => options = options + ("build_log_history=" + arg)),
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   612
          "o:" -> (arg => options = options + arg),
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   613
          "s:" -> (arg =>
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   614
            space_explode('x', arg).map(Value.Int.parse) match {
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   615
              case List(w, h) if w > 0 && h > 0 => image_size = (w, h)
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   616
              case _ => error("Error bad PNG image size: " + quote(arg))
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   617
            }),
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   618
          "v" -> (_ => verbose = true))
63688
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   619
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   620
        val more_args = getopts(args)
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   621
        if (more_args.nonEmpty) getopts.usage()
63700
2a95d904672e clarified options and arguments;
wenzelm
parents: 63688
diff changeset
   622
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   623
        val progress = new Console_Progress
63688
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   624
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   625
        build_status(options, progress = progress, only_sessions = only_sessions, verbose = verbose,
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   626
          target_dir = target_dir, ml_statistics = ml_statistics, image_size = image_size)
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   627
      })
63686
66f217416da7 statistics from session build output;
wenzelm
parents:
diff changeset
   628
}