src/Pure/Admin/build_log.scala
author wenzelm
Sun, 19 Nov 2023 12:51:47 +0100
changeset 78992 bd250213c262
parent 78991 ae2f5fd0bb5d
child 78995 b9d59669904a
permissions -rw-r--r--
unused (see also 004b39bf06a5);
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
64160
1eea419fab65 clarified files;
wenzelm
parents: 64155
diff changeset
     1
/*  Title:      Pure/Admin/build_log.scala
64045
c6160d0b0337 clarified modules;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
c6160d0b0337 clarified modules;
wenzelm
parents:
diff changeset
     3
65608
d526ba7b0a2d tuned comment;
wenzelm
parents: 65607
diff changeset
     4
Management of build log files and database storage.
64045
c6160d0b0337 clarified modules;
wenzelm
parents:
diff changeset
     5
*/
c6160d0b0337 clarified modules;
wenzelm
parents:
diff changeset
     6
c6160d0b0337 clarified modules;
wenzelm
parents:
diff changeset
     7
package isabelle
c6160d0b0337 clarified modules;
wenzelm
parents:
diff changeset
     8
c6160d0b0337 clarified modules;
wenzelm
parents:
diff changeset
     9
64100
9b1573213ebe tuned error;
wenzelm
parents: 64099
diff changeset
    10
import java.io.{File => JFile}
64110
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
    11
import java.time.format.{DateTimeFormatter, DateTimeParseException}
64096
5edeb60a7ec5 more flexible date formats;
wenzelm
parents: 64095
diff changeset
    12
import java.util.Locale
64061
1bbea2b55d22 some support for header and data fields, notably from afp-test;
wenzelm
parents: 64054
diff changeset
    13
65600
138ffa41dc54 clarified filter_files: sorted and unique;
wenzelm
parents: 65599
diff changeset
    14
import scala.collection.immutable.SortedMap
64054
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
    15
import scala.collection.mutable
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
    16
import scala.util.matching.Regex
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
    17
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
    18
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
    19
object Build_Log {
64298
wenzelm
parents: 64297
diff changeset
    20
  /** content **/
64101
976289c733e6 more formal directory content;
wenzelm
parents: 64100
diff changeset
    21
64298
wenzelm
parents: 64297
diff changeset
    22
  /* properties */
64150
b10f2ddd7679 clarified modules;
wenzelm
parents: 64120
diff changeset
    23
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
    24
  object Prop {
65624
32fa61f694ef clarified multi-line properties;
wenzelm
parents: 65623
diff changeset
    25
    val build_tags = SQL.Column.string("build_tags")  // lines
32fa61f694ef clarified multi-line properties;
wenzelm
parents: 65623
diff changeset
    26
    val build_args = SQL.Column.string("build_args")  // lines
65591
5953c7fbc2b8 more SQL operations;
wenzelm
parents: 65590
diff changeset
    27
    val build_group_id = SQL.Column.string("build_group_id")
5953c7fbc2b8 more SQL operations;
wenzelm
parents: 65590
diff changeset
    28
    val build_id = SQL.Column.string("build_id")
5953c7fbc2b8 more SQL operations;
wenzelm
parents: 65590
diff changeset
    29
    val build_engine = SQL.Column.string("build_engine")
5953c7fbc2b8 more SQL operations;
wenzelm
parents: 65590
diff changeset
    30
    val build_host = SQL.Column.string("build_host")
5953c7fbc2b8 more SQL operations;
wenzelm
parents: 65590
diff changeset
    31
    val build_start = SQL.Column.date("build_start")
5953c7fbc2b8 more SQL operations;
wenzelm
parents: 65590
diff changeset
    32
    val build_end = SQL.Column.date("build_end")
5953c7fbc2b8 more SQL operations;
wenzelm
parents: 65590
diff changeset
    33
    val isabelle_version = SQL.Column.string("isabelle_version")
5953c7fbc2b8 more SQL operations;
wenzelm
parents: 65590
diff changeset
    34
    val afp_version = SQL.Column.string("afp_version")
5953c7fbc2b8 more SQL operations;
wenzelm
parents: 65590
diff changeset
    35
65611
a4a7841ae84f more uniform storage of Meta_Info;
wenzelm
parents: 65609
diff changeset
    36
    val all_props: List[SQL.Column] =
65591
5953c7fbc2b8 more SQL operations;
wenzelm
parents: 65590
diff changeset
    37
      List(build_tags, build_args, build_group_id, build_id, build_engine,
5953c7fbc2b8 more SQL operations;
wenzelm
parents: 65590
diff changeset
    38
        build_host, build_start, build_end, isabelle_version, afp_version)
64298
wenzelm
parents: 64297
diff changeset
    39
  }
64150
b10f2ddd7679 clarified modules;
wenzelm
parents: 64120
diff changeset
    40
b10f2ddd7679 clarified modules;
wenzelm
parents: 64120
diff changeset
    41
64298
wenzelm
parents: 64297
diff changeset
    42
  /* settings */
64080
2e5c0bd708af clarified modules;
wenzelm
parents: 64079
diff changeset
    43
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
    44
  object Settings {
65611
a4a7841ae84f more uniform storage of Meta_Info;
wenzelm
parents: 65609
diff changeset
    45
    val ISABELLE_BUILD_OPTIONS = SQL.Column.string("ISABELLE_BUILD_OPTIONS")
a4a7841ae84f more uniform storage of Meta_Info;
wenzelm
parents: 65609
diff changeset
    46
    val ML_PLATFORM = SQL.Column.string("ML_PLATFORM")
a4a7841ae84f more uniform storage of Meta_Info;
wenzelm
parents: 65609
diff changeset
    47
    val ML_HOME = SQL.Column.string("ML_HOME")
a4a7841ae84f more uniform storage of Meta_Info;
wenzelm
parents: 65609
diff changeset
    48
    val ML_SYSTEM = SQL.Column.string("ML_SYSTEM")
a4a7841ae84f more uniform storage of Meta_Info;
wenzelm
parents: 65609
diff changeset
    49
    val ML_OPTIONS = SQL.Column.string("ML_OPTIONS")
a4a7841ae84f more uniform storage of Meta_Info;
wenzelm
parents: 65609
diff changeset
    50
a4a7841ae84f more uniform storage of Meta_Info;
wenzelm
parents: 65609
diff changeset
    51
    val ml_settings = List(ML_PLATFORM, ML_HOME, ML_SYSTEM, ML_OPTIONS)
a4a7841ae84f more uniform storage of Meta_Info;
wenzelm
parents: 65609
diff changeset
    52
    val all_settings = ISABELLE_BUILD_OPTIONS :: ml_settings
64081
38bb09ed965b more uniform treatment of settings;
wenzelm
parents: 64080
diff changeset
    53
38bb09ed965b more uniform treatment of settings;
wenzelm
parents: 64080
diff changeset
    54
    type Entry = (String, String)
38bb09ed965b more uniform treatment of settings;
wenzelm
parents: 64080
diff changeset
    55
    type T = List[Entry]
64080
2e5c0bd708af clarified modules;
wenzelm
parents: 64079
diff changeset
    56
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
    57
    object Entry {
64081
38bb09ed965b more uniform treatment of settings;
wenzelm
parents: 64080
diff changeset
    58
      def unapply(s: String): Option[Entry] =
73712
3eba8d4b624b clarified signature;
wenzelm
parents: 73344
diff changeset
    59
        for { (a, b) <- Properties.Eq.unapply(s) }
3eba8d4b624b clarified signature;
wenzelm
parents: 73344
diff changeset
    60
        yield (a, Library.perhaps_unquote(b))
73713
wenzelm
parents: 73712
diff changeset
    61
      def getenv(a: String): String =
73715
bf51c23f3f99 clarified signature -- avoid odd warning about scala/bug#6675;
wenzelm
parents: 73713
diff changeset
    62
        Properties.Eq(a, quote(Isabelle_System.getenv(a)))
64081
38bb09ed965b more uniform treatment of settings;
wenzelm
parents: 64080
diff changeset
    63
    }
64080
2e5c0bd708af clarified modules;
wenzelm
parents: 64079
diff changeset
    64
71992
c8c3f4f0f68b clarified log message (more uniform);
wenzelm
parents: 71982
diff changeset
    65
    def show(): String =
64081
38bb09ed965b more uniform treatment of settings;
wenzelm
parents: 64080
diff changeset
    66
      cat_lines(
71992
c8c3f4f0f68b clarified log message (more uniform);
wenzelm
parents: 71982
diff changeset
    67
        List(Entry.getenv("ISABELLE_TOOL_JAVA_OPTIONS"),
c8c3f4f0f68b clarified log message (more uniform);
wenzelm
parents: 71982
diff changeset
    68
          Entry.getenv(ISABELLE_BUILD_OPTIONS.name), "") :::
65611
a4a7841ae84f more uniform storage of Meta_Info;
wenzelm
parents: 65609
diff changeset
    69
        ml_settings.map(c => Entry.getenv(c.name)))
64080
2e5c0bd708af clarified modules;
wenzelm
parents: 64079
diff changeset
    70
  }
2e5c0bd708af clarified modules;
wenzelm
parents: 64079
diff changeset
    71
2e5c0bd708af clarified modules;
wenzelm
parents: 64079
diff changeset
    72
64298
wenzelm
parents: 64297
diff changeset
    73
  /* file names */
wenzelm
parents: 64297
diff changeset
    74
wenzelm
parents: 64297
diff changeset
    75
  def log_date(date: Date): String =
wenzelm
parents: 64297
diff changeset
    76
    String.format(Locale.ROOT, "%s.%05d",
wenzelm
parents: 64297
diff changeset
    77
      DateTimeFormatter.ofPattern("yyyy-MM-dd").format(date.rep),
71163
b5822f4c3fde tuned -- avoid deprecated constructors;
wenzelm
parents: 69980
diff changeset
    78
      java.lang.Long.valueOf((date.time - date.midnight.time).ms / 1000))
64298
wenzelm
parents: 64297
diff changeset
    79
wenzelm
parents: 64297
diff changeset
    80
  def log_subdir(date: Date): Path =
wenzelm
parents: 64297
diff changeset
    81
    Path.explode("log") + Path.explode(date.rep.getYear.toString)
wenzelm
parents: 64297
diff changeset
    82
wenzelm
parents: 64297
diff changeset
    83
  def log_filename(engine: String, date: Date, more: List[String] = Nil): Path =
wenzelm
parents: 64297
diff changeset
    84
    Path.explode((engine :: log_date(date) :: more).mkString("", "_", ".log"))
wenzelm
parents: 64297
diff changeset
    85
wenzelm
parents: 64297
diff changeset
    86
64100
9b1573213ebe tuned error;
wenzelm
parents: 64099
diff changeset
    87
64062
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
    88
  /** log file **/
64045
c6160d0b0337 clarified modules;
wenzelm
parents:
diff changeset
    89
64155
646c4d6a6a02 tuned signature;
wenzelm
parents: 64150
diff changeset
    90
  def print_date(date: Date): String = Log_File.Date_Format(date)
646c4d6a6a02 tuned signature;
wenzelm
parents: 64150
diff changeset
    91
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
    92
  object Log_File {
65607
c937984c70e9 tuned signature;
wenzelm
parents: 65605
diff changeset
    93
    /* log file */
c937984c70e9 tuned signature;
wenzelm
parents: 65605
diff changeset
    94
78856
wenzelm
parents: 78853
diff changeset
    95
    val all_suffixes: List[String] = List(".log", ".log.gz", ".log.xz", ".gz", ".xz")
wenzelm
parents: 78853
diff changeset
    96
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
    97
    def plain_name(name: String): String = {
78856
wenzelm
parents: 78853
diff changeset
    98
      all_suffixes.find(name.endsWith) match {
65609
9917b8e3b5c1 clarified plain_name / log_name;
wenzelm
parents: 65608
diff changeset
    99
        case Some(s) => Library.try_unsuffix(s, name).get
9917b8e3b5c1 clarified plain_name / log_name;
wenzelm
parents: 65608
diff changeset
   100
        case None => name
9917b8e3b5c1 clarified plain_name / log_name;
wenzelm
parents: 65608
diff changeset
   101
      }
9917b8e3b5c1 clarified plain_name / log_name;
wenzelm
parents: 65608
diff changeset
   102
    }
77748
5a2a297a91f8 more robust errors: proceed updating database;
wenzelm
parents: 77747
diff changeset
   103
    def plain_name(file: JFile): String = plain_name(file.getName)
65609
9917b8e3b5c1 clarified plain_name / log_name;
wenzelm
parents: 65608
diff changeset
   104
78985
24e686fe043e clarified Log_File.cache: reuse existing Store.cache / Build_Log.Store.cache;
wenzelm
parents: 78984
diff changeset
   105
    def apply(name: String, lines: List[String], cache: XML.Cache = XML.Cache.none): Log_File =
24e686fe043e clarified Log_File.cache: reuse existing Store.cache / Build_Log.Store.cache;
wenzelm
parents: 78984
diff changeset
   106
      new Log_File(plain_name(name), lines.map(s => cache.string(Library.trim_line(s))), cache)
64062
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   107
78985
24e686fe043e clarified Log_File.cache: reuse existing Store.cache / Build_Log.Store.cache;
wenzelm
parents: 78984
diff changeset
   108
    def read(file: JFile, cache: XML.Cache = XML.Cache.none): Log_File = {
64090
5a68280112b3 more operations;
wenzelm
parents: 64089
diff changeset
   109
      val name = file.getName
65609
9917b8e3b5c1 clarified plain_name / log_name;
wenzelm
parents: 65608
diff changeset
   110
      val text =
75906
2167b9e3157a clarified signature: support for adhoc file types;
wenzelm
parents: 75776
diff changeset
   111
        if (File.is_gz(name)) File.read_gzip(file)
78985
24e686fe043e clarified Log_File.cache: reuse existing Store.cache / Build_Log.Store.cache;
wenzelm
parents: 78984
diff changeset
   112
        else if (File.is_xz(name)) Bytes.read(file).uncompress_xz(cache = cache.compress).text
65609
9917b8e3b5c1 clarified plain_name / log_name;
wenzelm
parents: 65608
diff changeset
   113
        else File.read(file)
78985
24e686fe043e clarified Log_File.cache: reuse existing Store.cache / Build_Log.Store.cache;
wenzelm
parents: 78984
diff changeset
   114
      apply(name, Library.trim_split_lines(text), cache = cache)
64090
5a68280112b3 more operations;
wenzelm
parents: 64089
diff changeset
   115
    }
5a68280112b3 more operations;
wenzelm
parents: 64089
diff changeset
   116
64110
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   117
65607
c937984c70e9 tuned signature;
wenzelm
parents: 65605
diff changeset
   118
    /* log file collections */
c937984c70e9 tuned signature;
wenzelm
parents: 65605
diff changeset
   119
78856
wenzelm
parents: 78853
diff changeset
   120
    val log_prefixes: List[String] =
wenzelm
parents: 78853
diff changeset
   121
      List(Build_History.log_prefix, Identify.log_prefix, Identify.log_prefix2,
wenzelm
parents: 78853
diff changeset
   122
        Isatest.log_prefix, AFP_Test.log_prefix)
wenzelm
parents: 78853
diff changeset
   123
wenzelm
parents: 78853
diff changeset
   124
    val log_suffixes: List[String] = List(".log", ".log.gz", ".log.xz")
wenzelm
parents: 78853
diff changeset
   125
65607
c937984c70e9 tuned signature;
wenzelm
parents: 65605
diff changeset
   126
    def is_log(file: JFile,
78856
wenzelm
parents: 78853
diff changeset
   127
      prefixes: List[String] = log_prefixes,
wenzelm
parents: 78853
diff changeset
   128
      suffixes: List[String] = log_suffixes
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
   129
    ): Boolean = {
65607
c937984c70e9 tuned signature;
wenzelm
parents: 65605
diff changeset
   130
      val name = file.getName
65639
4c14da234221 exclude special log files;
wenzelm
parents: 65636
diff changeset
   131
71621
wenzelm
parents: 71620
diff changeset
   132
      prefixes.exists(name.startsWith) &&
wenzelm
parents: 71620
diff changeset
   133
      suffixes.exists(name.endsWith) &&
65639
4c14da234221 exclude special log files;
wenzelm
parents: 65636
diff changeset
   134
      name != "isatest.log" &&
4c14da234221 exclude special log files;
wenzelm
parents: 65636
diff changeset
   135
      name != "afp-test.log" &&
4c14da234221 exclude special log files;
wenzelm
parents: 65636
diff changeset
   136
      name != "main.log"
65607
c937984c70e9 tuned signature;
wenzelm
parents: 65605
diff changeset
   137
    }
c937984c70e9 tuned signature;
wenzelm
parents: 65605
diff changeset
   138
78857
a79bd9d82c00 tuned signature;
wenzelm
parents: 78856
diff changeset
   139
    def find_files(starts: List[JFile]): List[JFile] =
a79bd9d82c00 tuned signature;
wenzelm
parents: 78856
diff changeset
   140
      starts.flatMap(start => File.find_files(start, pred = is_log(_), follow_links = true))
a79bd9d82c00 tuned signature;
wenzelm
parents: 78856
diff changeset
   141
        .sortBy(plain_name)
a79bd9d82c00 tuned signature;
wenzelm
parents: 78856
diff changeset
   142
65607
c937984c70e9 tuned signature;
wenzelm
parents: 65605
diff changeset
   143
64110
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   144
    /* date format */
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   145
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
   146
    val Date_Format = {
64101
976289c733e6 more formal directory content;
wenzelm
parents: 64100
diff changeset
   147
      val fmts =
976289c733e6 more formal directory content;
wenzelm
parents: 64100
diff changeset
   148
        Date.Formatter.variants(
64116
6cfd429a4296 prefer explicit timezone offset for printing;
wenzelm
parents: 64111
diff changeset
   149
          List("EEE MMM d HH:mm:ss O yyyy", "EEE MMM d HH:mm:ss VV yyyy"),
64104
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   150
          List(Locale.ENGLISH, Locale.GERMAN)) :::
64110
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   151
        List(
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   152
          DateTimeFormatter.RFC_1123_DATE_TIME,
69980
f2e3adfd916f tuned signature;
wenzelm
parents: 69299
diff changeset
   153
          Date.Formatter.pattern("EEE MMM d HH:mm:ss yyyy").withZone(Date.timezone_berlin))
64101
976289c733e6 more formal directory content;
wenzelm
parents: 64100
diff changeset
   154
64104
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   155
      def tune_timezone(s: String): String =
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   156
        s match {
64101
976289c733e6 more formal directory content;
wenzelm
parents: 64100
diff changeset
   157
          case "CET" | "MET" => "GMT+1"
976289c733e6 more formal directory content;
wenzelm
parents: 64100
diff changeset
   158
          case "CEST" | "MEST" => "GMT+2"
64104
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   159
          case "EST" => "Europe/Berlin"
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   160
          case _ => s
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   161
        }
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   162
      def tune_weekday(s: String): String =
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   163
        s match {
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   164
          case "Die" => "Di"
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   165
          case "Mit" => "Mi"
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   166
          case "Don" => "Do"
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   167
          case "Fre" => "Fr"
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   168
          case "Sam" => "Sa"
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   169
          case "Son" => "So"
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   170
          case _ => s
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   171
        }
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   172
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   173
      def tune(s: String): String =
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   174
        Word.implode(
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   175
          Word.explode(s) match {
71621
wenzelm
parents: 71620
diff changeset
   176
            case a :: "M\uFFFDr" :: bs => tune_weekday(a) :: "Mär" :: bs.map(tune_timezone)
wenzelm
parents: 71620
diff changeset
   177
            case a :: bs => tune_weekday(a) :: bs.map(tune_timezone)
64104
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   178
            case Nil => Nil
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   179
          }
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   180
        )
64101
976289c733e6 more formal directory content;
wenzelm
parents: 64100
diff changeset
   181
976289c733e6 more formal directory content;
wenzelm
parents: 64100
diff changeset
   182
      Date.Format.make(fmts, tune)
976289c733e6 more formal directory content;
wenzelm
parents: 64100
diff changeset
   183
    }
64102
1ec2adddf16b prefer static Date_Format;
wenzelm
parents: 64101
diff changeset
   184
  }
1ec2adddf16b prefer static Date_Format;
wenzelm
parents: 64101
diff changeset
   185
78985
24e686fe043e clarified Log_File.cache: reuse existing Store.cache / Build_Log.Store.cache;
wenzelm
parents: 78984
diff changeset
   186
  class Log_File private(
24e686fe043e clarified Log_File.cache: reuse existing Store.cache / Build_Log.Store.cache;
wenzelm
parents: 78984
diff changeset
   187
    val name: String,
24e686fe043e clarified Log_File.cache: reuse existing Store.cache / Build_Log.Store.cache;
wenzelm
parents: 78984
diff changeset
   188
    val lines: List[String],
24e686fe043e clarified Log_File.cache: reuse existing Store.cache / Build_Log.Store.cache;
wenzelm
parents: 78984
diff changeset
   189
    val cache: XML.Cache
24e686fe043e clarified Log_File.cache: reuse existing Store.cache / Build_Log.Store.cache;
wenzelm
parents: 78984
diff changeset
   190
  ) {
64102
1ec2adddf16b prefer static Date_Format;
wenzelm
parents: 64101
diff changeset
   191
    log_file =>
1ec2adddf16b prefer static Date_Format;
wenzelm
parents: 64101
diff changeset
   192
1ec2adddf16b prefer static Date_Format;
wenzelm
parents: 64101
diff changeset
   193
    override def toString: String = name
1ec2adddf16b prefer static Date_Format;
wenzelm
parents: 64101
diff changeset
   194
1ec2adddf16b prefer static Date_Format;
wenzelm
parents: 64101
diff changeset
   195
    def text: String = cat_lines(lines)
1ec2adddf16b prefer static Date_Format;
wenzelm
parents: 64101
diff changeset
   196
1ec2adddf16b prefer static Date_Format;
wenzelm
parents: 64101
diff changeset
   197
    def err(msg: String): Nothing =
77750
a8c52c99fa92 tuned messages;
wenzelm
parents: 77749
diff changeset
   198
      error("Bad log file " + quote(name) + ": " + msg)
64102
1ec2adddf16b prefer static Date_Format;
wenzelm
parents: 64101
diff changeset
   199
1ec2adddf16b prefer static Date_Format;
wenzelm
parents: 64101
diff changeset
   200
1ec2adddf16b prefer static Date_Format;
wenzelm
parents: 64101
diff changeset
   201
    /* date format */
64101
976289c733e6 more formal directory content;
wenzelm
parents: 64100
diff changeset
   202
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
   203
    object Strict_Date {
64101
976289c733e6 more formal directory content;
wenzelm
parents: 64100
diff changeset
   204
      def unapply(s: String): Some[Date] =
64102
1ec2adddf16b prefer static Date_Format;
wenzelm
parents: 64101
diff changeset
   205
        try { Some(Log_File.Date_Format.parse(s)) }
64101
976289c733e6 more formal directory content;
wenzelm
parents: 64100
diff changeset
   206
        catch { case exn: DateTimeParseException => log_file.err(exn.getMessage) }
976289c733e6 more formal directory content;
wenzelm
parents: 64100
diff changeset
   207
    }
976289c733e6 more formal directory content;
wenzelm
parents: 64100
diff changeset
   208
976289c733e6 more formal directory content;
wenzelm
parents: 64100
diff changeset
   209
71620
5a4ccef7f310 more explicit type Protocol_Message.Marker;
wenzelm
parents: 71163
diff changeset
   210
    /* inlined text */
64062
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   211
71620
5a4ccef7f310 more explicit type Protocol_Message.Marker;
wenzelm
parents: 71163
diff changeset
   212
    def filter(Marker: Protocol_Message.Marker): List[String] =
78592
fdfe9b91d96e misc tuning: support "scalac -source 3.3";
wenzelm
parents: 78400
diff changeset
   213
      for (case Marker(text) <- lines) yield text
64062
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   214
71620
5a4ccef7f310 more explicit type Protocol_Message.Marker;
wenzelm
parents: 71163
diff changeset
   215
    def find(Marker: Protocol_Message.Marker): Option[String] =
5a4ccef7f310 more explicit type Protocol_Message.Marker;
wenzelm
parents: 71163
diff changeset
   216
      lines.collectFirst({ case Marker(text) => text })
64196
6688b9cd443b more robust wrt. old versions that use clear-text properties (e.g. Timing in build_history_base);
wenzelm
parents: 64193
diff changeset
   217
65684
00d4663270d9 explicit support for multiple regexes;
wenzelm
parents: 65683
diff changeset
   218
    def find_match(regexes: List[Regex]): Option[String] =
00d4663270d9 explicit support for multiple regexes;
wenzelm
parents: 65683
diff changeset
   219
      regexes match {
00d4663270d9 explicit support for multiple regexes;
wenzelm
parents: 65683
diff changeset
   220
        case Nil => None
00d4663270d9 explicit support for multiple regexes;
wenzelm
parents: 65683
diff changeset
   221
        case regex :: rest =>
00d4663270d9 explicit support for multiple regexes;
wenzelm
parents: 65683
diff changeset
   222
          lines.iterator.map(regex.unapplySeq(_)).find(res => res.isDefined && res.get.length == 1).
00d4663270d9 explicit support for multiple regexes;
wenzelm
parents: 65683
diff changeset
   223
            map(res => res.get.head) orElse find_match(rest)
00d4663270d9 explicit support for multiple regexes;
wenzelm
parents: 65683
diff changeset
   224
      }
64062
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   225
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   226
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   227
    /* settings */
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   228
73715
bf51c23f3f99 clarified signature -- avoid odd warning about scala/bug#6675;
wenzelm
parents: 73713
diff changeset
   229
    def get_setting(name: String): Option[Settings.Entry] =
bf51c23f3f99 clarified signature -- avoid odd warning about scala/bug#6675;
wenzelm
parents: 73713
diff changeset
   230
      lines.collectFirst({ case Settings.Entry(a, b) if a == name => a -> b })
64045
c6160d0b0337 clarified modules;
wenzelm
parents:
diff changeset
   231
65611
a4a7841ae84f more uniform storage of Meta_Info;
wenzelm
parents: 65609
diff changeset
   232
    def get_all_settings: Settings.T =
a4a7841ae84f more uniform storage of Meta_Info;
wenzelm
parents: 65609
diff changeset
   233
      for { c <- Settings.all_settings; entry <- get_setting(c.name) }
a4a7841ae84f more uniform storage of Meta_Info;
wenzelm
parents: 65609
diff changeset
   234
      yield entry
64062
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   235
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   236
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   237
    /* properties (YXML) */
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   238
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   239
    def parse_props(text: String): Properties.T =
78985
24e686fe043e clarified Log_File.cache: reuse existing Store.cache / Build_Log.Store.cache;
wenzelm
parents: 78984
diff changeset
   240
      try { cache.props(XML.Decode.properties(YXML.parse_body(text, cache = cache))) }
66046
37226f74f33a tuned message;
wenzelm
parents: 65937
diff changeset
   241
      catch { case _: XML.Error => log_file.err("malformed properties") }
64062
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   242
71620
5a4ccef7f310 more explicit type Protocol_Message.Marker;
wenzelm
parents: 71163
diff changeset
   243
    def filter_props(marker: Protocol_Message.Marker): List[Properties.T] =
5a4ccef7f310 more explicit type Protocol_Message.Marker;
wenzelm
parents: 71163
diff changeset
   244
      for (text <- filter(marker) if YXML.detect(text)) yield parse_props(text)
64062
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   245
71620
5a4ccef7f310 more explicit type Protocol_Message.Marker;
wenzelm
parents: 71163
diff changeset
   246
    def find_props(marker: Protocol_Message.Marker): Option[Properties.T] =
5a4ccef7f310 more explicit type Protocol_Message.Marker;
wenzelm
parents: 71163
diff changeset
   247
      for (text <- find(marker) if YXML.detect(text)) yield parse_props(text)
64062
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   248
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   249
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   250
    /* parse various formats */
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   251
64105
d93bd6d253c6 tuned signature;
wenzelm
parents: 64104
diff changeset
   252
    def parse_meta_info(): Meta_Info = Build_Log.parse_meta_info(log_file)
d93bd6d253c6 tuned signature;
wenzelm
parents: 64104
diff changeset
   253
65646
014dbbe5331f parse ml_statistics only when required;
wenzelm
parents: 65645
diff changeset
   254
    def parse_build_info(ml_statistics: Boolean = false): Build_Info =
014dbbe5331f parse ml_statistics only when required;
wenzelm
parents: 65645
diff changeset
   255
      Build_Log.parse_build_info(log_file, ml_statistics)
64105
d93bd6d253c6 tuned signature;
wenzelm
parents: 64104
diff changeset
   256
64082
d57c7295f601 clarified signature;
wenzelm
parents: 64081
diff changeset
   257
    def parse_session_info(
d57c7295f601 clarified signature;
wenzelm
parents: 64081
diff changeset
   258
        command_timings: Boolean = false,
66873
9953ae603a23 provide theory timing information, similar to command timing but always considered relevant;
wenzelm
parents: 66863
diff changeset
   259
        theory_timings: Boolean = false,
64082
d57c7295f601 clarified signature;
wenzelm
parents: 64081
diff changeset
   260
        ml_statistics: Boolean = false,
d57c7295f601 clarified signature;
wenzelm
parents: 64081
diff changeset
   261
        task_statistics: Boolean = false): Session_Info =
66873
9953ae603a23 provide theory timing information, similar to command timing but always considered relevant;
wenzelm
parents: 66863
diff changeset
   262
      Build_Log.parse_session_info(
9953ae603a23 provide theory timing information, similar to command timing but always considered relevant;
wenzelm
parents: 66863
diff changeset
   263
        log_file, command_timings, theory_timings, ml_statistics, task_statistics)
64045
c6160d0b0337 clarified modules;
wenzelm
parents:
diff changeset
   264
  }
c6160d0b0337 clarified modules;
wenzelm
parents:
diff changeset
   265
c6160d0b0337 clarified modules;
wenzelm
parents:
diff changeset
   266
64098
099518e8af2c misc tuning and clarification;
wenzelm
parents: 64096
diff changeset
   267
75518
cb4af8c6152f clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents: 75394
diff changeset
   268
  /** digested meta info: produced by Admin/build_other in log.xz file **/
64045
c6160d0b0337 clarified modules;
wenzelm
parents:
diff changeset
   269
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
   270
  object Meta_Info {
64108
623abb8fecdf clarified meta info;
wenzelm
parents: 64107
diff changeset
   271
    val empty: Meta_Info = Meta_Info(Nil, Nil)
64099
wenzelm
parents: 64098
diff changeset
   272
  }
64098
099518e8af2c misc tuning and clarification;
wenzelm
parents: 64096
diff changeset
   273
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
   274
  sealed case class Meta_Info(props: Properties.T, settings: Settings.T) {
64103
60d163f38056 accept spurious empty logs;
wenzelm
parents: 64102
diff changeset
   275
    def is_empty: Boolean = props.isEmpty && settings.isEmpty
65599
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   276
65611
a4a7841ae84f more uniform storage of Meta_Info;
wenzelm
parents: 65609
diff changeset
   277
    def get(c: SQL.Column): Option[String] =
a4a7841ae84f more uniform storage of Meta_Info;
wenzelm
parents: 65609
diff changeset
   278
      Properties.get(props, c.name) orElse
a4a7841ae84f more uniform storage of Meta_Info;
wenzelm
parents: 65609
diff changeset
   279
      Properties.get(settings, c.name)
a4a7841ae84f more uniform storage of Meta_Info;
wenzelm
parents: 65609
diff changeset
   280
a4a7841ae84f more uniform storage of Meta_Info;
wenzelm
parents: 65609
diff changeset
   281
    def get_date(c: SQL.Column): Option[Date] =
71621
wenzelm
parents: 71620
diff changeset
   282
      get(c).map(Log_File.Date_Format.parse)
64103
60d163f38056 accept spurious empty logs;
wenzelm
parents: 64102
diff changeset
   283
  }
64061
1bbea2b55d22 some support for header and data fields, notably from afp-test;
wenzelm
parents: 64054
diff changeset
   284
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
   285
  object Identify {
65625
13552d5c0005 more log files;
wenzelm
parents: 65624
diff changeset
   286
    val log_prefix = "isabelle_identify_"
66995
9cb263dbb2f7 plain identify job for Isabelle + AFP, independent of any Isabelle technology;
wenzelm
parents: 66944
diff changeset
   287
    val log_prefix2 = "plain_identify_"
65674
23897f5d885d approximate repository identify job based on isabelle-nightly-slow;
wenzelm
parents: 65670
diff changeset
   288
23897f5d885d approximate repository identify job based on isabelle-nightly-slow;
wenzelm
parents: 65670
diff changeset
   289
    def engine(log_file: Log_File): String =
77133
536c033fb6eb removed somewhat pointless support for Jenkins log files: it has stopped working long ago;
wenzelm
parents: 77113
diff changeset
   290
      if (log_file.name.startsWith(log_prefix2)) "plain_identify" else "identify"
65674
23897f5d885d approximate repository identify job based on isabelle-nightly-slow;
wenzelm
parents: 65670
diff changeset
   291
23897f5d885d approximate repository identify job based on isabelle-nightly-slow;
wenzelm
parents: 65670
diff changeset
   292
    def content(date: Date, isabelle_version: Option[String], afp_version: Option[String]): String =
23897f5d885d approximate repository identify job based on isabelle-nightly-slow;
wenzelm
parents: 65670
diff changeset
   293
      terminate_lines(
23897f5d885d approximate repository identify job based on isabelle-nightly-slow;
wenzelm
parents: 65670
diff changeset
   294
        List("isabelle_identify: " + Build_Log.print_date(date), "") :::
23897f5d885d approximate repository identify job based on isabelle-nightly-slow;
wenzelm
parents: 65670
diff changeset
   295
        isabelle_version.map("Isabelle version: " + _).toList :::
23897f5d885d approximate repository identify job based on isabelle-nightly-slow;
wenzelm
parents: 65670
diff changeset
   296
        afp_version.map("AFP version: " + _).toList)
23897f5d885d approximate repository identify job based on isabelle-nightly-slow;
wenzelm
parents: 65670
diff changeset
   297
65625
13552d5c0005 more log files;
wenzelm
parents: 65624
diff changeset
   298
    val Start = new Regex("""^isabelle_identify: (.+)$""")
13552d5c0005 more log files;
wenzelm
parents: 65624
diff changeset
   299
    val No_End = new Regex("""$.""")
65684
00d4663270d9 explicit support for multiple regexes;
wenzelm
parents: 65683
diff changeset
   300
    val Isabelle_Version = List(new Regex("""^Isabelle version: (\S+)$"""))
00d4663270d9 explicit support for multiple regexes;
wenzelm
parents: 65683
diff changeset
   301
    val AFP_Version = List(new Regex("""^AFP version: (\S+)$"""))
65625
13552d5c0005 more log files;
wenzelm
parents: 65624
diff changeset
   302
  }
13552d5c0005 more log files;
wenzelm
parents: 65624
diff changeset
   303
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
   304
  object Isatest {
65588
b0d8d97198b3 clarified signature;
wenzelm
parents: 65318
diff changeset
   305
    val log_prefix = "isatest-makeall-"
64108
623abb8fecdf clarified meta info;
wenzelm
parents: 64107
diff changeset
   306
    val engine = "isatest"
64109
wenzelm
parents: 64108
diff changeset
   307
    val Start = new Regex("""^------------------- starting test --- (.+) --- (.+)$""")
wenzelm
parents: 64108
diff changeset
   308
    val End = new Regex("""^------------------- test (?:successful|FAILED) --- (.+) --- .*$""")
65684
00d4663270d9 explicit support for multiple regexes;
wenzelm
parents: 65683
diff changeset
   309
    val Isabelle_Version = List(new Regex("""^Isabelle version: (\S+)$"""))
64095
1a6d37c31df9 support for isatest format;
wenzelm
parents: 64094
diff changeset
   310
  }
1a6d37c31df9 support for isatest format;
wenzelm
parents: 64094
diff changeset
   311
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
   312
  object AFP_Test {
65588
b0d8d97198b3 clarified signature;
wenzelm
parents: 65318
diff changeset
   313
    val log_prefix = "afp-test-devel-"
64108
623abb8fecdf clarified meta info;
wenzelm
parents: 64107
diff changeset
   314
    val engine = "afp-test"
64109
wenzelm
parents: 64108
diff changeset
   315
    val Start = new Regex("""^Start test(?: for .+)? at ([^,]+), (.*)$""")
wenzelm
parents: 64108
diff changeset
   316
    val Start_Old = new Regex("""^Start test(?: for .+)? at ([^,]+)$""")
wenzelm
parents: 64108
diff changeset
   317
    val End = new Regex("""^End test on (.+), .+, elapsed time:.*$""")
65684
00d4663270d9 explicit support for multiple regexes;
wenzelm
parents: 65683
diff changeset
   318
    val Isabelle_Version = List(new Regex("""^Isabelle version: .* -- hg id (\S+)$"""))
00d4663270d9 explicit support for multiple regexes;
wenzelm
parents: 65683
diff changeset
   319
    val AFP_Version = List(new Regex("""^AFP version: .* -- hg id (\S+)$"""))
64104
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   320
    val Bad_Init = new Regex("""^cp:.*: Disc quota exceeded$""")
64061
1bbea2b55d22 some support for header and data fields, notably from afp-test;
wenzelm
parents: 64054
diff changeset
   321
  }
1bbea2b55d22 some support for header and data fields, notably from afp-test;
wenzelm
parents: 64054
diff changeset
   322
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
   323
  object Jenkins {
65664
c84db5e0dd6d detect Jenkins log files as well;
wenzelm
parents: 65663
diff changeset
   324
    val log_prefix = "jenkins_"
64110
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   325
    val engine = "jenkins"
65663
61cd86bb9613 detect host name;
wenzelm
parents: 65649
diff changeset
   326
    val Host = new Regex("""^Building remotely on (\S+) \((\S+)\).*$""")
65665
9b7fb07b4a96 more robust detection of Jenkins log;
wenzelm
parents: 65664
diff changeset
   327
    val Start = new Regex("""^(?:Started by an SCM change|Started from command line by admin|).*$""")
64110
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   328
    val Start_Date = new Regex("""^Build started at (.+)$""")
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   329
    val No_End = new Regex("""$.""")
65674
23897f5d885d approximate repository identify job based on isabelle-nightly-slow;
wenzelm
parents: 65670
diff changeset
   330
    val Isabelle_Version =
65684
00d4663270d9 explicit support for multiple regexes;
wenzelm
parents: 65683
diff changeset
   331
      List(new Regex("""^(?:Build for Isabelle id|Isabelle id) (\w+).*$"""),
65685
47bbf7150aae detect old log files (early 2016);
wenzelm
parents: 65684
diff changeset
   332
        new Regex("""^ISABELLE_CI_REPO_ID="(\w+)".*$"""),
47bbf7150aae detect old log files (early 2016);
wenzelm
parents: 65684
diff changeset
   333
        new Regex("""^(\w{12}) tip.*$"""))
65674
23897f5d885d approximate repository identify job based on isabelle-nightly-slow;
wenzelm
parents: 65670
diff changeset
   334
    val AFP_Version =
65684
00d4663270d9 explicit support for multiple regexes;
wenzelm
parents: 65683
diff changeset
   335
      List(new Regex("""^(?:Build for AFP id|AFP id) (\w+).*$"""),
00d4663270d9 explicit support for multiple regexes;
wenzelm
parents: 65683
diff changeset
   336
        new Regex("""^ISABELLE_CI_AFP_ID="(\w+)".*$"""))
64110
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   337
    val CONFIGURATION = "=== CONFIGURATION ==="
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   338
    val BUILD = "=== BUILD ==="
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   339
  }
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   340
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
   341
  private def parse_meta_info(log_file: Log_File): Meta_Info = {
64108
623abb8fecdf clarified meta info;
wenzelm
parents: 64107
diff changeset
   342
    def parse(engine: String, host: String, start: Date,
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
   343
      End: Regex, Isabelle_Version: List[Regex], AFP_Version: List[Regex]
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
   344
    ): Meta_Info = {
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
   345
      val build_id = {
65714
wenzelm
parents: 65709
diff changeset
   346
        val prefix = proper_string(host) orElse proper_string(engine) getOrElse "build"
wenzelm
parents: 65709
diff changeset
   347
        prefix + ":" + start.time.ms
64296
544481988e65 explicit identification of builds and correlated build groups;
wenzelm
parents: 64196
diff changeset
   348
      }
65591
5953c7fbc2b8 more SQL operations;
wenzelm
parents: 65590
diff changeset
   349
      val build_engine = if (engine == "") Nil else List(Prop.build_engine.name -> engine)
5953c7fbc2b8 more SQL operations;
wenzelm
parents: 65590
diff changeset
   350
      val build_host = if (host == "") Nil else List(Prop.build_host.name -> host)
64108
623abb8fecdf clarified meta info;
wenzelm
parents: 64107
diff changeset
   351
65599
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   352
      val start_date = List(Prop.build_start.name -> print_date(start))
64091
f8dfba90e73f more liberal parsing for old AFP logs;
wenzelm
parents: 64090
diff changeset
   353
      val end_date =
f8dfba90e73f more liberal parsing for old AFP logs;
wenzelm
parents: 64090
diff changeset
   354
        log_file.lines.last match {
64109
wenzelm
parents: 64108
diff changeset
   355
          case End(log_file.Strict_Date(end_date)) =>
65599
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   356
            List(Prop.build_end.name -> print_date(end_date))
64091
f8dfba90e73f more liberal parsing for old AFP logs;
wenzelm
parents: 64090
diff changeset
   357
          case _ => Nil
f8dfba90e73f more liberal parsing for old AFP logs;
wenzelm
parents: 64090
diff changeset
   358
        }
f8dfba90e73f more liberal parsing for old AFP logs;
wenzelm
parents: 64090
diff changeset
   359
f8dfba90e73f more liberal parsing for old AFP logs;
wenzelm
parents: 64090
diff changeset
   360
      val isabelle_version =
65591
5953c7fbc2b8 more SQL operations;
wenzelm
parents: 65590
diff changeset
   361
        log_file.find_match(Isabelle_Version).map(Prop.isabelle_version.name -> _)
64091
f8dfba90e73f more liberal parsing for old AFP logs;
wenzelm
parents: 64090
diff changeset
   362
      val afp_version =
65591
5953c7fbc2b8 more SQL operations;
wenzelm
parents: 65590
diff changeset
   363
        log_file.find_match(AFP_Version).map(Prop.afp_version.name -> _)
64062
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   364
65591
5953c7fbc2b8 more SQL operations;
wenzelm
parents: 65590
diff changeset
   365
      Meta_Info((Prop.build_id.name -> build_id) :: build_engine ::: build_host :::
64108
623abb8fecdf clarified meta info;
wenzelm
parents: 64107
diff changeset
   366
          start_date ::: end_date ::: isabelle_version.toList ::: afp_version.toList,
65611
a4a7841ae84f more uniform storage of Meta_Info;
wenzelm
parents: 65609
diff changeset
   367
        log_file.get_all_settings)
64091
f8dfba90e73f more liberal parsing for old AFP logs;
wenzelm
parents: 64090
diff changeset
   368
    }
f8dfba90e73f more liberal parsing for old AFP logs;
wenzelm
parents: 64090
diff changeset
   369
f8dfba90e73f more liberal parsing for old AFP logs;
wenzelm
parents: 64090
diff changeset
   370
    log_file.lines match {
71630
50425e4c3910 clarified modules: global quasi-scope for markers;
wenzelm
parents: 71621
diff changeset
   371
      case line :: _ if Protocol.Meta_Info_Marker.test_yxml(line) =>
50425e4c3910 clarified modules: global quasi-scope for markers;
wenzelm
parents: 71621
diff changeset
   372
        Meta_Info(log_file.find_props(Protocol.Meta_Info_Marker).get, log_file.get_all_settings)
64117
c2b41b073d8a build_history log files with formal meta info;
wenzelm
parents: 64116
diff changeset
   373
65625
13552d5c0005 more log files;
wenzelm
parents: 65624
diff changeset
   374
      case Identify.Start(log_file.Strict_Date(start)) :: _ =>
65674
23897f5d885d approximate repository identify job based on isabelle-nightly-slow;
wenzelm
parents: 65670
diff changeset
   375
        parse(Identify.engine(log_file), "", start, Identify.No_End,
65625
13552d5c0005 more log files;
wenzelm
parents: 65624
diff changeset
   376
          Identify.Isabelle_Version, Identify.AFP_Version)
13552d5c0005 more log files;
wenzelm
parents: 65624
diff changeset
   377
64109
wenzelm
parents: 64108
diff changeset
   378
      case Isatest.Start(log_file.Strict_Date(start), host) :: _ =>
wenzelm
parents: 64108
diff changeset
   379
        parse(Isatest.engine, host, start, Isatest.End,
65684
00d4663270d9 explicit support for multiple regexes;
wenzelm
parents: 65683
diff changeset
   380
          Isatest.Isabelle_Version, Nil)
64099
wenzelm
parents: 64098
diff changeset
   381
64109
wenzelm
parents: 64108
diff changeset
   382
      case AFP_Test.Start(log_file.Strict_Date(start), host) :: _ =>
wenzelm
parents: 64108
diff changeset
   383
        parse(AFP_Test.engine, host, start, AFP_Test.End,
wenzelm
parents: 64108
diff changeset
   384
          AFP_Test.Isabelle_Version, AFP_Test.AFP_Version)
64099
wenzelm
parents: 64098
diff changeset
   385
64109
wenzelm
parents: 64108
diff changeset
   386
      case AFP_Test.Start_Old(log_file.Strict_Date(start)) :: _ =>
wenzelm
parents: 64108
diff changeset
   387
        parse(AFP_Test.engine, "", start, AFP_Test.End,
wenzelm
parents: 64108
diff changeset
   388
          AFP_Test.Isabelle_Version, AFP_Test.AFP_Version)
64099
wenzelm
parents: 64098
diff changeset
   389
64341
45b6faeee56d avoid deprecated Scala;
wenzelm
parents: 64303
diff changeset
   390
      case line :: _ if line.startsWith("\u0000") => Meta_Info.empty
64109
wenzelm
parents: 64108
diff changeset
   391
      case List(Isatest.End(_)) => Meta_Info.empty
wenzelm
parents: 64108
diff changeset
   392
      case _ :: AFP_Test.Bad_Init() :: _ => Meta_Info.empty
64105
d93bd6d253c6 tuned signature;
wenzelm
parents: 64104
diff changeset
   393
      case Nil => Meta_Info.empty
64104
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   394
64110
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   395
      case _ => log_file.err("cannot detect log file format")
64061
1bbea2b55d22 some support for header and data fields, notably from afp-test;
wenzelm
parents: 64054
diff changeset
   396
    }
1bbea2b55d22 some support for header and data fields, notably from afp-test;
wenzelm
parents: 64054
diff changeset
   397
  }
1bbea2b55d22 some support for header and data fields, notably from afp-test;
wenzelm
parents: 64054
diff changeset
   398
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   399
64098
099518e8af2c misc tuning and clarification;
wenzelm
parents: 64096
diff changeset
   400
75518
cb4af8c6152f clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents: 75394
diff changeset
   401
  /** build info: toplevel output of isabelle build or Admin/build_other **/
64119
8094eaa38d4b inline session ML statistics into main build log;
wenzelm
parents: 64117
diff changeset
   402
8094eaa38d4b inline session ML statistics into main build log;
wenzelm
parents: 64117
diff changeset
   403
  val SESSION_NAME = "session_name"
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   404
78608
0e01c3b55b63 clarified signature: prefer enum types;
wenzelm
parents: 78592
diff changeset
   405
  enum Session_Status { case existing, finished, failed, cancelled }
64061
1bbea2b55d22 some support for header and data fields, notably from afp-test;
wenzelm
parents: 64054
diff changeset
   406
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   407
  sealed case class Session_Entry(
65643
a54371226182 clarified dummy Session_Entry;
wenzelm
parents: 65642
diff changeset
   408
    chapter: String = "",
a54371226182 clarified dummy Session_Entry;
wenzelm
parents: 65642
diff changeset
   409
    groups: List[String] = Nil,
78836
dd350a41594c defined statically known tables of Build_Log;
Fabian Huch <huch@in.tum.de>
parents: 78768
diff changeset
   410
    hostname: Option[String] = None,
65643
a54371226182 clarified dummy Session_Entry;
wenzelm
parents: 65642
diff changeset
   411
    threads: Option[Int] = None,
a54371226182 clarified dummy Session_Entry;
wenzelm
parents: 65642
diff changeset
   412
    timing: Timing = Timing.zero,
a54371226182 clarified dummy Session_Entry;
wenzelm
parents: 65642
diff changeset
   413
    ml_timing: Timing = Timing.zero,
66913
7cdd4d59e95c store session sources stamp;
wenzelm
parents: 66880
diff changeset
   414
    sources: Option[String] = None,
77113
c301b97b4301 more explicit types;
wenzelm
parents: 76870
diff changeset
   415
    heap_size: Option[Space] = None,
78608
0e01c3b55b63 clarified signature: prefer enum types;
wenzelm
parents: 78592
diff changeset
   416
    status: Option[Session_Status] = None,
65937
fde7b5d209d5 store errors in build_history logs and database;
wenzelm
parents: 65934
diff changeset
   417
    errors: List[String] = Nil,
66874
0b8da0fc9563 store theory timings in session in build_log database;
wenzelm
parents: 66873
diff changeset
   418
    theory_timings: Map[String, Timing] = Map.empty,
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
   419
    ml_statistics: List[Properties.T] = Nil
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
   420
  ) {
65631
ee917f172912 clarified database content;
wenzelm
parents: 65629
diff changeset
   421
    def proper_groups: Option[String] = if (groups.isEmpty) None else Some(cat_lines(groups))
65643
a54371226182 clarified dummy Session_Entry;
wenzelm
parents: 65642
diff changeset
   422
    def finished: Boolean = status == Some(Session_Status.finished)
65937
fde7b5d209d5 store errors in build_history logs and database;
wenzelm
parents: 65934
diff changeset
   423
    def failed: Boolean = status == Some(Session_Status.failed)
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   424
  }
64054
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   425
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
   426
  object Build_Info {
66874
0b8da0fc9563 store theory timings in session in build_log database;
wenzelm
parents: 66873
diff changeset
   427
    val sessions_dummy: Map[String, Session_Entry] =
0b8da0fc9563 store theory timings in session in build_log database;
wenzelm
parents: 66873
diff changeset
   428
      Map("" -> Session_Entry(theory_timings = Map("" -> Timing.zero)))
0b8da0fc9563 store theory timings in session in build_log database;
wenzelm
parents: 66873
diff changeset
   429
  }
0b8da0fc9563 store theory timings in session in build_log database;
wenzelm
parents: 66873
diff changeset
   430
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
   431
  sealed case class Build_Info(sessions: Map[String, Session_Entry]) {
65937
fde7b5d209d5 store errors in build_history logs and database;
wenzelm
parents: 65934
diff changeset
   432
    def finished_sessions: List[String] = for ((a, b) <- sessions.toList if b.finished) yield a
fde7b5d209d5 store errors in build_history logs and database;
wenzelm
parents: 65934
diff changeset
   433
    def failed_sessions: List[String] = for ((a, b) <- sessions.toList if b.failed) yield a
64054
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   434
  }
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   435
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
   436
  private def parse_build_info(log_file: Log_File, parse_ml_statistics: Boolean): Build_Info = {
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
   437
    object Chapter_Name {
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   438
      def unapply(s: String): Some[(String, String)] =
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   439
        space_explode('/', s) match {
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   440
          case List(chapter, name) => Some((chapter, name))
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   441
          case _ => Some(("", s))
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   442
        }
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   443
    }
64054
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   444
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   445
    val Session_No_Groups = new Regex("""^Session (\S+)$""")
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   446
    val Session_Groups = new Regex("""^Session (\S+) \((.*)\)$""")
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   447
    val Session_Finished1 =
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   448
      new Regex("""^Finished (\S+) \((\d+):(\d+):(\d+) elapsed time, (\d+):(\d+):(\d+) cpu time.*$""")
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   449
    val Session_Finished2 =
72695
45cd55248ffd clarified messages;
wenzelm
parents: 72694
diff changeset
   450
      new Regex("""^Finished ([^\s/]+) \((\d+):(\d+):(\d+) elapsed time.*$""")
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   451
    val Session_Timing =
65679
45632d594bdb more general pattern;
wenzelm
parents: 65674
diff changeset
   452
      new Regex("""^Timing (\S+) \((\d+) threads, (\d+\.\d+)s elapsed time, (\d+\.\d+)s cpu time, (\d+\.\d+)s GC time.*$""")
77551
ae6df8a8685a clarified messages;
wenzelm
parents: 77544
diff changeset
   453
    val Session_Started1 = new Regex("""^(?:Running|Building) (\S+) \.\.\.$""")
78843
fc3ba0a1c82f read relative cpu from build log;
Fabian Huch <huch@in.tum.de>
parents: 78836
diff changeset
   454
    val Session_Started2 = new Regex("""^(?:Running|Building) (\S+) \(?on ([^\s/]+)/?(\d+)\+?(\S+)\)? \.\.\.$""")
66913
7cdd4d59e95c store session sources stamp;
wenzelm
parents: 66880
diff changeset
   455
    val Sources = new Regex("""^Sources (\S+) (\S{""" + SHA1.digest_length + """})$""")
64120
6c5039016321 record heap sizes;
wenzelm
parents: 64119
diff changeset
   456
    val Heap = new Regex("""^Heap (\S+) \((\d+) bytes\)$""")
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   457
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
   458
    object Theory_Timing {
66874
0b8da0fc9563 store theory timings in session in build_log database;
wenzelm
parents: 66873
diff changeset
   459
      def unapply(line: String): Option[(String, (String, Timing))] =
71630
50425e4c3910 clarified modules: global quasi-scope for markers;
wenzelm
parents: 71621
diff changeset
   460
        Protocol.Theory_Timing_Marker.unapply(line.replace('~', '-')).map(log_file.parse_props)
50425e4c3910 clarified modules: global quasi-scope for markers;
wenzelm
parents: 71621
diff changeset
   461
        match {
72753
e8da2cfdfcff more robust (amending a4d7da18ac5c);
wenzelm
parents: 72695
diff changeset
   462
          case Some((SESSION_NAME, session) :: props) =>
e8da2cfdfcff more robust (amending a4d7da18ac5c);
wenzelm
parents: 72695
diff changeset
   463
            for (theory <- Markup.Name.unapply(props))
74782
0a87ea7eb76f clarified signature;
wenzelm
parents: 73715
diff changeset
   464
            yield (session, theory -> Markup.Timing_Properties.get(props))
66874
0b8da0fc9563 store theory timings in session in build_log database;
wenzelm
parents: 66873
diff changeset
   465
          case _ => None
0b8da0fc9563 store theory timings in session in build_log database;
wenzelm
parents: 66873
diff changeset
   466
        }
0b8da0fc9563 store theory timings in session in build_log database;
wenzelm
parents: 66873
diff changeset
   467
    }
0b8da0fc9563 store theory timings in session in build_log database;
wenzelm
parents: 66873
diff changeset
   468
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   469
    var chapter = Map.empty[String, String]
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   470
    var groups = Map.empty[String, List[String]]
78836
dd350a41594c defined statically known tables of Build_Log;
Fabian Huch <huch@in.tum.de>
parents: 78768
diff changeset
   471
    var hostnames = Map.empty[String, String]
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   472
    var threads = Map.empty[String, Int]
64054
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   473
    var timing = Map.empty[String, Timing]
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   474
    var ml_timing = Map.empty[String, Timing]
64086
ac7ae5067783 clarified status: started sessions may bomb without explicit FAILED or CANCELLED (cf. in afp-test-devel-2016-01-03.log);
wenzelm
parents: 64085
diff changeset
   475
    var started = Set.empty[String]
66913
7cdd4d59e95c store session sources stamp;
wenzelm
parents: 66880
diff changeset
   476
    var sources = Map.empty[String, String]
77113
c301b97b4301 more explicit types;
wenzelm
parents: 76870
diff changeset
   477
    var heap_sizes = Map.empty[String, Space]
66874
0b8da0fc9563 store theory timings in session in build_log database;
wenzelm
parents: 66873
diff changeset
   478
    var theory_timings = Map.empty[String, Map[String, Timing]]
64119
8094eaa38d4b inline session ML statistics into main build log;
wenzelm
parents: 64117
diff changeset
   479
    var ml_statistics = Map.empty[String, List[Properties.T]]
65937
fde7b5d209d5 store errors in build_history logs and database;
wenzelm
parents: 65934
diff changeset
   480
    var errors = Map.empty[String, List[String]]
64119
8094eaa38d4b inline session ML statistics into main build log;
wenzelm
parents: 64117
diff changeset
   481
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   482
    def all_sessions: Set[String] =
64120
6c5039016321 record heap sizes;
wenzelm
parents: 64119
diff changeset
   483
      chapter.keySet ++ groups.keySet ++ threads.keySet ++ timing.keySet ++ ml_timing.keySet ++
72694
0116e487e4fe unused (see ac7ae5067783, 1c451e5c145f);
wenzelm
parents: 72375
diff changeset
   484
      started ++ sources.keySet ++ heap_sizes.keySet ++
66913
7cdd4d59e95c store session sources stamp;
wenzelm
parents: 66880
diff changeset
   485
      theory_timings.keySet ++ ml_statistics.keySet
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   486
64054
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   487
64062
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   488
    for (line <- log_file.lines) {
64054
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   489
      line match {
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   490
        case Session_No_Groups(Chapter_Name(chapt, name)) =>
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   491
          chapter += (name -> chapt)
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   492
          groups += (name -> Nil)
64119
8094eaa38d4b inline session ML statistics into main build log;
wenzelm
parents: 64117
diff changeset
   493
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   494
        case Session_Groups(Chapter_Name(chapt, name), grps) =>
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   495
          chapter += (name -> chapt)
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   496
          groups += (name -> Word.explode(grps))
64119
8094eaa38d4b inline session ML statistics into main build log;
wenzelm
parents: 64117
diff changeset
   497
77551
ae6df8a8685a clarified messages;
wenzelm
parents: 77544
diff changeset
   498
        case Session_Started1(name) =>
ae6df8a8685a clarified messages;
wenzelm
parents: 77544
diff changeset
   499
          started += name
ae6df8a8685a clarified messages;
wenzelm
parents: 77544
diff changeset
   500
78843
fc3ba0a1c82f read relative cpu from build log;
Fabian Huch <huch@in.tum.de>
parents: 78836
diff changeset
   501
        case Session_Started2(name, hostname, numa_node, rel_cpus) =>
64086
ac7ae5067783 clarified status: started sessions may bomb without explicit FAILED or CANCELLED (cf. in afp-test-devel-2016-01-03.log);
wenzelm
parents: 64085
diff changeset
   502
          started += name
78836
dd350a41594c defined statically known tables of Build_Log;
Fabian Huch <huch@in.tum.de>
parents: 78768
diff changeset
   503
          hostnames += (name -> hostname)
64119
8094eaa38d4b inline session ML statistics into main build log;
wenzelm
parents: 64117
diff changeset
   504
64054
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   505
        case Session_Finished1(name,
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   506
            Value.Int(e1), Value.Int(e2), Value.Int(e3),
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   507
            Value.Int(c1), Value.Int(c2), Value.Int(c3)) =>
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   508
          val elapsed = Time.hms(e1, e2, e3)
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   509
          val cpu = Time.hms(c1, c2, c3)
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   510
          timing += (name -> Timing(elapsed, cpu, Time.zero))
64119
8094eaa38d4b inline session ML statistics into main build log;
wenzelm
parents: 64117
diff changeset
   511
64054
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   512
        case Session_Finished2(name,
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   513
            Value.Int(e1), Value.Int(e2), Value.Int(e3)) =>
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   514
          val elapsed = Time.hms(e1, e2, e3)
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   515
          timing += (name -> Timing(elapsed, Time.zero, Time.zero))
64119
8094eaa38d4b inline session ML statistics into main build log;
wenzelm
parents: 64117
diff changeset
   516
64054
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   517
        case Session_Timing(name,
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   518
            Value.Int(t), Value.Double(e), Value.Double(c), Value.Double(g)) =>
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   519
          val elapsed = Time.seconds(e)
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   520
          val cpu = Time.seconds(c)
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   521
          val gc = Time.seconds(g)
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   522
          ml_timing += (name -> Timing(elapsed, cpu, gc))
64054
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   523
          threads += (name -> t)
64119
8094eaa38d4b inline session ML statistics into main build log;
wenzelm
parents: 64117
diff changeset
   524
66913
7cdd4d59e95c store session sources stamp;
wenzelm
parents: 66880
diff changeset
   525
        case Sources(name, s) =>
7cdd4d59e95c store session sources stamp;
wenzelm
parents: 66880
diff changeset
   526
          sources += (name -> s)
7cdd4d59e95c store session sources stamp;
wenzelm
parents: 66880
diff changeset
   527
64120
6c5039016321 record heap sizes;
wenzelm
parents: 64119
diff changeset
   528
        case Heap(name, Value.Long(size)) =>
77113
c301b97b4301 more explicit types;
wenzelm
parents: 76870
diff changeset
   529
          heap_sizes += (name -> Space.bytes(size))
64120
6c5039016321 record heap sizes;
wenzelm
parents: 64119
diff changeset
   530
71630
50425e4c3910 clarified modules: global quasi-scope for markers;
wenzelm
parents: 71621
diff changeset
   531
        case _ if Protocol.Theory_Timing_Marker.test_yxml(line) =>
66874
0b8da0fc9563 store theory timings in session in build_log database;
wenzelm
parents: 66873
diff changeset
   532
          line match {
0b8da0fc9563 store theory timings in session in build_log database;
wenzelm
parents: 66873
diff changeset
   533
            case Theory_Timing(name, theory_timing) =>
0b8da0fc9563 store theory timings in session in build_log database;
wenzelm
parents: 66873
diff changeset
   534
              theory_timings += (name -> (theory_timings.getOrElse(name, Map.empty) + theory_timing))
0b8da0fc9563 store theory timings in session in build_log database;
wenzelm
parents: 66873
diff changeset
   535
            case _ => log_file.err("malformed theory_timing " + quote(line))
0b8da0fc9563 store theory timings in session in build_log database;
wenzelm
parents: 66873
diff changeset
   536
          }
0b8da0fc9563 store theory timings in session in build_log database;
wenzelm
parents: 66873
diff changeset
   537
71630
50425e4c3910 clarified modules: global quasi-scope for markers;
wenzelm
parents: 71621
diff changeset
   538
        case _ if parse_ml_statistics && Protocol.ML_Statistics_Marker.test_yxml(line) =>
50425e4c3910 clarified modules: global quasi-scope for markers;
wenzelm
parents: 71621
diff changeset
   539
          Protocol.ML_Statistics_Marker.unapply(line).map(log_file.parse_props) match {
66874
0b8da0fc9563 store theory timings in session in build_log database;
wenzelm
parents: 66873
diff changeset
   540
            case Some((SESSION_NAME, name) :: props) =>
0b8da0fc9563 store theory timings in session in build_log database;
wenzelm
parents: 66873
diff changeset
   541
              ml_statistics += (name -> (props :: ml_statistics.getOrElse(name, Nil)))
0b8da0fc9563 store theory timings in session in build_log database;
wenzelm
parents: 66873
diff changeset
   542
            case _ => log_file.err("malformed ML_statistics " + quote(line))
0b8da0fc9563 store theory timings in session in build_log database;
wenzelm
parents: 66873
diff changeset
   543
          }
64119
8094eaa38d4b inline session ML statistics into main build log;
wenzelm
parents: 64117
diff changeset
   544
71630
50425e4c3910 clarified modules: global quasi-scope for markers;
wenzelm
parents: 71621
diff changeset
   545
        case _ if Protocol.Error_Message_Marker.test_yxml(line) =>
50425e4c3910 clarified modules: global quasi-scope for markers;
wenzelm
parents: 71621
diff changeset
   546
          Protocol.Error_Message_Marker.unapply(line).map(log_file.parse_props) match {
66874
0b8da0fc9563 store theory timings in session in build_log database;
wenzelm
parents: 66873
diff changeset
   547
            case Some(List((SESSION_NAME, name), (Markup.CONTENT, msg))) =>
71620
5a4ccef7f310 more explicit type Protocol_Message.Marker;
wenzelm
parents: 71163
diff changeset
   548
              errors += (name -> (msg :: errors.getOrElse(name, Nil)))
66874
0b8da0fc9563 store theory timings in session in build_log database;
wenzelm
parents: 66873
diff changeset
   549
            case _ => log_file.err("malformed error message " + quote(line))
0b8da0fc9563 store theory timings in session in build_log database;
wenzelm
parents: 66873
diff changeset
   550
          }
65937
fde7b5d209d5 store errors in build_history logs and database;
wenzelm
parents: 65934
diff changeset
   551
64054
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   552
        case _ =>
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   553
      }
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   554
    }
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   555
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   556
    val sessions =
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   557
      Map(
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   558
        (for (name <- all_sessions.toList) yield {
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   559
          val status =
72694
0116e487e4fe unused (see ac7ae5067783, 1c451e5c145f);
wenzelm
parents: 72375
diff changeset
   560
            if (timing.isDefinedAt(name) || ml_timing.isDefinedAt(name))
65633
wenzelm
parents: 65632
diff changeset
   561
              Session_Status.finished
wenzelm
parents: 65632
diff changeset
   562
            else if (started(name)) Session_Status.failed
wenzelm
parents: 65632
diff changeset
   563
            else Session_Status.existing
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   564
          val entry =
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   565
            Session_Entry(
65643
a54371226182 clarified dummy Session_Entry;
wenzelm
parents: 65642
diff changeset
   566
              chapter = chapter.getOrElse(name, ""),
a54371226182 clarified dummy Session_Entry;
wenzelm
parents: 65642
diff changeset
   567
              groups = groups.getOrElse(name, Nil),
78836
dd350a41594c defined statically known tables of Build_Log;
Fabian Huch <huch@in.tum.de>
parents: 78768
diff changeset
   568
              hostname = hostnames.get(name),
65643
a54371226182 clarified dummy Session_Entry;
wenzelm
parents: 65642
diff changeset
   569
              threads = threads.get(name),
a54371226182 clarified dummy Session_Entry;
wenzelm
parents: 65642
diff changeset
   570
              timing = timing.getOrElse(name, Timing.zero),
a54371226182 clarified dummy Session_Entry;
wenzelm
parents: 65642
diff changeset
   571
              ml_timing = ml_timing.getOrElse(name, Timing.zero),
66913
7cdd4d59e95c store session sources stamp;
wenzelm
parents: 66880
diff changeset
   572
              sources = sources.get(name),
65643
a54371226182 clarified dummy Session_Entry;
wenzelm
parents: 65642
diff changeset
   573
              heap_size = heap_sizes.get(name),
a54371226182 clarified dummy Session_Entry;
wenzelm
parents: 65642
diff changeset
   574
              status = Some(status),
65937
fde7b5d209d5 store errors in build_history logs and database;
wenzelm
parents: 65934
diff changeset
   575
              errors = errors.getOrElse(name, Nil).reverse,
66874
0b8da0fc9563 store theory timings in session in build_log database;
wenzelm
parents: 66873
diff changeset
   576
              theory_timings = theory_timings.getOrElse(name, Map.empty),
65643
a54371226182 clarified dummy Session_Entry;
wenzelm
parents: 65642
diff changeset
   577
              ml_statistics = ml_statistics.getOrElse(name, Nil).reverse)
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   578
          (name -> entry)
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   579
        }):_*)
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   580
    Build_Info(sessions)
64054
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   581
  }
64099
wenzelm
parents: 64098
diff changeset
   582
wenzelm
parents: 64098
diff changeset
   583
wenzelm
parents: 64098
diff changeset
   584
72860
64378eaf393d tuned comments;
wenzelm
parents: 72753
diff changeset
   585
  /** session info: produced by isabelle build as session database **/
64099
wenzelm
parents: 64098
diff changeset
   586
wenzelm
parents: 64098
diff changeset
   587
  sealed case class Session_Info(
wenzelm
parents: 64098
diff changeset
   588
    session_timing: Properties.T,
wenzelm
parents: 64098
diff changeset
   589
    command_timings: List[Properties.T],
66873
9953ae603a23 provide theory timing information, similar to command timing but always considered relevant;
wenzelm
parents: 66863
diff changeset
   590
    theory_timings: List[Properties.T],
64099
wenzelm
parents: 64098
diff changeset
   591
    ml_statistics: List[Properties.T],
65934
5f202ba9f590 store errors in build db;
wenzelm
parents: 65857
diff changeset
   592
    task_statistics: List[Properties.T],
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
   593
    errors: List[String]
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
   594
  ) {
66944
05df740cb54b more informative timeout message, notably for build_status;
wenzelm
parents: 66913
diff changeset
   595
    def error(s: String): Session_Info =
05df740cb54b more informative timeout message, notably for build_status;
wenzelm
parents: 66913
diff changeset
   596
      copy(errors = errors ::: List(s))
05df740cb54b more informative timeout message, notably for build_status;
wenzelm
parents: 66913
diff changeset
   597
  }
64099
wenzelm
parents: 64098
diff changeset
   598
wenzelm
parents: 64098
diff changeset
   599
  private def parse_session_info(
wenzelm
parents: 64098
diff changeset
   600
    log_file: Log_File,
wenzelm
parents: 64098
diff changeset
   601
    command_timings: Boolean,
66873
9953ae603a23 provide theory timing information, similar to command timing but always considered relevant;
wenzelm
parents: 66863
diff changeset
   602
    theory_timings: Boolean,
64099
wenzelm
parents: 64098
diff changeset
   603
    ml_statistics: Boolean,
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
   604
    task_statistics: Boolean
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
   605
  ): Session_Info = {
65290
wenzelm
parents: 65276
diff changeset
   606
    Session_Info(
72012
c81e58a81b8c clarified inlined protocol messages;
wenzelm
parents: 71992
diff changeset
   607
      session_timing = log_file.find_props(Protocol.Session_Timing_Marker) getOrElse Nil,
71630
50425e4c3910 clarified modules: global quasi-scope for markers;
wenzelm
parents: 71621
diff changeset
   608
      command_timings =
50425e4c3910 clarified modules: global quasi-scope for markers;
wenzelm
parents: 71621
diff changeset
   609
        if (command_timings) log_file.filter_props(Protocol.Command_Timing_Marker) else Nil,
50425e4c3910 clarified modules: global quasi-scope for markers;
wenzelm
parents: 71621
diff changeset
   610
      theory_timings =
50425e4c3910 clarified modules: global quasi-scope for markers;
wenzelm
parents: 71621
diff changeset
   611
        if (theory_timings) log_file.filter_props(Protocol.Theory_Timing_Marker) else Nil,
50425e4c3910 clarified modules: global quasi-scope for markers;
wenzelm
parents: 71621
diff changeset
   612
      ml_statistics =
50425e4c3910 clarified modules: global quasi-scope for markers;
wenzelm
parents: 71621
diff changeset
   613
        if (ml_statistics) log_file.filter_props(Protocol.ML_Statistics_Marker) else Nil,
50425e4c3910 clarified modules: global quasi-scope for markers;
wenzelm
parents: 71621
diff changeset
   614
      task_statistics =
50425e4c3910 clarified modules: global quasi-scope for markers;
wenzelm
parents: 71621
diff changeset
   615
        if (task_statistics) log_file.filter_props(Protocol.Task_Statistics_Marker) else Nil,
50425e4c3910 clarified modules: global quasi-scope for markers;
wenzelm
parents: 71621
diff changeset
   616
      errors = log_file.filter(Protocol.Error_Message_Marker))
64099
wenzelm
parents: 64098
diff changeset
   617
  }
65595
ffd8283b7be0 support for database connection;
wenzelm
parents: 65591
diff changeset
   618
76351
2cee31cd92f0 generic support for XZ and Zstd compression in Isabelle/Scala;
wenzelm
parents: 76350
diff changeset
   619
  def compress_errors(
2cee31cd92f0 generic support for XZ and Zstd compression in Isabelle/Scala;
wenzelm
parents: 76350
diff changeset
   620
    errors: List[String],
2cee31cd92f0 generic support for XZ and Zstd compression in Isabelle/Scala;
wenzelm
parents: 76350
diff changeset
   621
    cache: Compress.Cache = Compress.Cache.none
2cee31cd92f0 generic support for XZ and Zstd compression in Isabelle/Scala;
wenzelm
parents: 76350
diff changeset
   622
  ): Option[Bytes] =
65937
fde7b5d209d5 store errors in build_history logs and database;
wenzelm
parents: 65934
diff changeset
   623
    if (errors.isEmpty) None
68018
3747fe57eb67 support for XZ.Cache;
wenzelm
parents: 67743
diff changeset
   624
    else {
3747fe57eb67 support for XZ.Cache;
wenzelm
parents: 67743
diff changeset
   625
      Some(Bytes(YXML.string_of_body(XML.Encode.list(XML.Encode.string)(errors))).
3747fe57eb67 support for XZ.Cache;
wenzelm
parents: 67743
diff changeset
   626
        compress(cache = cache))
3747fe57eb67 support for XZ.Cache;
wenzelm
parents: 67743
diff changeset
   627
    }
65937
fde7b5d209d5 store errors in build_history logs and database;
wenzelm
parents: 65934
diff changeset
   628
73033
d2690444c00a clarified caching;
wenzelm
parents: 73031
diff changeset
   629
  def uncompress_errors(bytes: Bytes, cache: XML.Cache = XML.Cache.make()): List[String] =
72885
1b0f81e556a2 accommodate OpenJDK 15;
wenzelm
parents: 72860
diff changeset
   630
    if (bytes.is_empty) Nil
68018
3747fe57eb67 support for XZ.Cache;
wenzelm
parents: 67743
diff changeset
   631
    else {
73033
d2690444c00a clarified caching;
wenzelm
parents: 73031
diff changeset
   632
      XML.Decode.list(YXML.string_of_body)(
76351
2cee31cd92f0 generic support for XZ and Zstd compression in Isabelle/Scala;
wenzelm
parents: 76350
diff changeset
   633
        YXML.parse_body(bytes.uncompress(cache = cache.compress).text, cache = cache))
68018
3747fe57eb67 support for XZ.Cache;
wenzelm
parents: 67743
diff changeset
   634
    }
65937
fde7b5d209d5 store errors in build_history logs and database;
wenzelm
parents: 65934
diff changeset
   635
65595
ffd8283b7be0 support for database connection;
wenzelm
parents: 65591
diff changeset
   636
ffd8283b7be0 support for database connection;
wenzelm
parents: 65591
diff changeset
   637
ffd8283b7be0 support for database connection;
wenzelm
parents: 65591
diff changeset
   638
  /** persistent store **/
ffd8283b7be0 support for database connection;
wenzelm
parents: 65591
diff changeset
   639
65694
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   640
  /* SQL data model */
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   641
78849
df162316b6a7 clarified names;
wenzelm
parents: 78843
diff changeset
   642
  object private_data extends SQL.Data("isabelle_build_log") {
78836
dd350a41594c defined statically known tables of Build_Log;
Fabian Huch <huch@in.tum.de>
parents: 78768
diff changeset
   643
    override def tables: SQL.Tables =
dd350a41594c defined statically known tables of Build_Log;
Fabian Huch <huch@in.tum.de>
parents: 78768
diff changeset
   644
      SQL.Tables(
dd350a41594c defined statically known tables of Build_Log;
Fabian Huch <huch@in.tum.de>
parents: 78768
diff changeset
   645
        meta_info_table,
dd350a41594c defined statically known tables of Build_Log;
Fabian Huch <huch@in.tum.de>
parents: 78768
diff changeset
   646
        sessions_table,
dd350a41594c defined statically known tables of Build_Log;
Fabian Huch <huch@in.tum.de>
parents: 78768
diff changeset
   647
        theories_table,
78852
2700e4b484f7 removed obsolete table (see also 6acd1a2bd146);
wenzelm
parents: 78851
diff changeset
   648
        ml_statistics_table)
78389
41e8ae87184d clarified signature: eliminate SQL.Tables.empty to avoid confusion (see also 0bd366fad888);
wenzelm
parents: 78352
diff changeset
   649
41e8ae87184d clarified signature: eliminate SQL.Tables.empty to avoid confusion (see also 0bd366fad888);
wenzelm
parents: 78352
diff changeset
   650
65694
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   651
    /* main content */
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   652
66857
f8f42289c4df tuned signature;
wenzelm
parents: 66856
diff changeset
   653
    val log_name = SQL.Column.string("log_name").make_primary_key
f8f42289c4df tuned signature;
wenzelm
parents: 66856
diff changeset
   654
    val session_name = SQL.Column.string("session_name").make_primary_key
66874
0b8da0fc9563 store theory timings in session in build_log database;
wenzelm
parents: 66873
diff changeset
   655
    val theory_name = SQL.Column.string("theory_name").make_primary_key
65694
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   656
    val chapter = SQL.Column.string("chapter")
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   657
    val groups = SQL.Column.string("groups")
78836
dd350a41594c defined statically known tables of Build_Log;
Fabian Huch <huch@in.tum.de>
parents: 78768
diff changeset
   658
    val hostname = SQL.Column.string("hostname")
65694
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   659
    val threads = SQL.Column.int("threads")
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   660
    val timing_elapsed = SQL.Column.long("timing_elapsed")
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   661
    val timing_cpu = SQL.Column.long("timing_cpu")
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   662
    val timing_gc = SQL.Column.long("timing_gc")
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   663
    val timing_factor = SQL.Column.double("timing_factor")
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   664
    val ml_timing_elapsed = SQL.Column.long("ml_timing_elapsed")
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   665
    val ml_timing_cpu = SQL.Column.long("ml_timing_cpu")
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   666
    val ml_timing_gc = SQL.Column.long("ml_timing_gc")
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   667
    val ml_timing_factor = SQL.Column.double("ml_timing_factor")
66874
0b8da0fc9563 store theory timings in session in build_log database;
wenzelm
parents: 66873
diff changeset
   668
    val theory_timing_elapsed = SQL.Column.long("theory_timing_elapsed")
0b8da0fc9563 store theory timings in session in build_log database;
wenzelm
parents: 66873
diff changeset
   669
    val theory_timing_cpu = SQL.Column.long("theory_timing_cpu")
0b8da0fc9563 store theory timings in session in build_log database;
wenzelm
parents: 66873
diff changeset
   670
    val theory_timing_gc = SQL.Column.long("theory_timing_gc")
65694
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   671
    val heap_size = SQL.Column.long("heap_size")
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   672
    val status = SQL.Column.string("status")
65937
fde7b5d209d5 store errors in build_history logs and database;
wenzelm
parents: 65934
diff changeset
   673
    val errors = SQL.Column.bytes("errors")
66913
7cdd4d59e95c store session sources stamp;
wenzelm
parents: 66880
diff changeset
   674
    val sources = SQL.Column.string("sources")
65694
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   675
    val ml_statistics = SQL.Column.bytes("ml_statistics")
65783
d3d5cb2d6866 pick isabelle_version based on build_log database;
wenzelm
parents: 65781
diff changeset
   676
    val known = SQL.Column.bool("known")
65694
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   677
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   678
    val meta_info_table =
78266
d8c99a497502 clarified signature;
wenzelm
parents: 78187
diff changeset
   679
      make_table(log_name :: Prop.all_props ::: Settings.all_settings, name = "meta_info")
65694
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   680
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   681
    val sessions_table =
78266
d8c99a497502 clarified signature;
wenzelm
parents: 78187
diff changeset
   682
      make_table(
78836
dd350a41594c defined statically known tables of Build_Log;
Fabian Huch <huch@in.tum.de>
parents: 78768
diff changeset
   683
        List(log_name, session_name, chapter, groups, hostname, threads, timing_elapsed, timing_cpu,
65694
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   684
          timing_gc, timing_factor, ml_timing_elapsed, ml_timing_cpu, ml_timing_gc, ml_timing_factor,
78266
d8c99a497502 clarified signature;
wenzelm
parents: 78187
diff changeset
   685
          heap_size, status, errors, sources),
d8c99a497502 clarified signature;
wenzelm
parents: 78187
diff changeset
   686
        name = "sessions")
65694
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   687
66874
0b8da0fc9563 store theory timings in session in build_log database;
wenzelm
parents: 66873
diff changeset
   688
    val theories_table =
78266
d8c99a497502 clarified signature;
wenzelm
parents: 78187
diff changeset
   689
      make_table(
66874
0b8da0fc9563 store theory timings in session in build_log database;
wenzelm
parents: 66873
diff changeset
   690
        List(log_name, session_name, theory_name, theory_timing_elapsed, theory_timing_cpu,
78266
d8c99a497502 clarified signature;
wenzelm
parents: 78187
diff changeset
   691
          theory_timing_gc),
d8c99a497502 clarified signature;
wenzelm
parents: 78187
diff changeset
   692
        name = "theories")
66874
0b8da0fc9563 store theory timings in session in build_log database;
wenzelm
parents: 66873
diff changeset
   693
65694
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   694
    val ml_statistics_table =
78266
d8c99a497502 clarified signature;
wenzelm
parents: 78187
diff changeset
   695
      make_table(List(log_name, session_name, ml_statistics), name = "ml_statistics")
65694
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   696
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   697
65705
d0ca2a3ea657 more snapshot content;
wenzelm
parents: 65703
diff changeset
   698
    /* earliest pull date for repository version (PostgreSQL queries) */
65694
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   699
71621
wenzelm
parents: 71620
diff changeset
   700
    def pull_date(afp: Boolean = false): SQL.Column =
66880
486f4af28db9 more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents: 66874
diff changeset
   701
      if (afp) SQL.Column.date("afp_pull_date")
486f4af28db9 more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents: 66874
diff changeset
   702
      else SQL.Column.date("pull_date")
65694
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   703
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
   704
    def pull_date_table(afp: Boolean = false): SQL.Table = {
66863
6acd1a2bd146 clarified afp_pull_date: both repository versions are relevant;
wenzelm
parents: 66858
diff changeset
   705
      val (name, versions) =
6acd1a2bd146 clarified afp_pull_date: both repository versions are relevant;
wenzelm
parents: 66858
diff changeset
   706
        if (afp) ("afp_pull_date", List(Prop.isabelle_version, Prop.afp_version))
6acd1a2bd146 clarified afp_pull_date: both repository versions are relevant;
wenzelm
parents: 66858
diff changeset
   707
        else ("pull_date", List(Prop.isabelle_version))
65694
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   708
78266
d8c99a497502 clarified signature;
wenzelm
parents: 78187
diff changeset
   709
      make_table(versions.map(_.make_primary_key) ::: List(pull_date(afp)),
d8c99a497502 clarified signature;
wenzelm
parents: 78187
diff changeset
   710
        body =
d8c99a497502 clarified signature;
wenzelm
parents: 78187
diff changeset
   711
          "SELECT " + versions.mkString(", ") +
d8c99a497502 clarified signature;
wenzelm
parents: 78187
diff changeset
   712
            ", min(" + Prop.build_start + ") AS " + pull_date(afp) +
d8c99a497502 clarified signature;
wenzelm
parents: 78187
diff changeset
   713
          " FROM " + meta_info_table +
d8c99a497502 clarified signature;
wenzelm
parents: 78187
diff changeset
   714
          " WHERE " + SQL.AND((versions ::: List(Prop.build_start)).map(_.defined)) +
d8c99a497502 clarified signature;
wenzelm
parents: 78187
diff changeset
   715
          " GROUP BY " + versions.mkString(", "),
d8c99a497502 clarified signature;
wenzelm
parents: 78187
diff changeset
   716
        name = name)
66855
c9d413fca1ec support for AFP versions;
wenzelm
parents: 66046
diff changeset
   717
    }
c9d413fca1ec support for AFP versions;
wenzelm
parents: 66046
diff changeset
   718
c9d413fca1ec support for AFP versions;
wenzelm
parents: 66046
diff changeset
   719
c9d413fca1ec support for AFP versions;
wenzelm
parents: 66046
diff changeset
   720
    /* recent entries */
c9d413fca1ec support for AFP versions;
wenzelm
parents: 66046
diff changeset
   721
78921
2fee5fba3116 proper default for disjunction (amending 9f7a94117666);
wenzelm
parents: 78900
diff changeset
   722
    def recent(c: SQL.Column, days: Int, default: PostgreSQL.Source = ""): PostgreSQL.Source =
2fee5fba3116 proper default for disjunction (amending 9f7a94117666);
wenzelm
parents: 78900
diff changeset
   723
      if (days <= 0) default
78900
9f7a94117666 clarified "recent" time: days <= 0 means infinity (no constraint);
wenzelm
parents: 78894
diff changeset
   724
      else c.ident + " > now() - INTERVAL '" + days + " days'"
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65729
diff changeset
   725
66863
6acd1a2bd146 clarified afp_pull_date: both repository versions are relevant;
wenzelm
parents: 66858
diff changeset
   726
    def recent_pull_date_table(
78900
9f7a94117666 clarified "recent" time: days <= 0 means infinity (no constraint);
wenzelm
parents: 78894
diff changeset
   727
      days: Int = 0,
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
   728
      rev: String = "",
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
   729
      afp_rev: Option[String] = None
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
   730
    ): SQL.Table = {
66863
6acd1a2bd146 clarified afp_pull_date: both repository versions are relevant;
wenzelm
parents: 66858
diff changeset
   731
      val afp = afp_rev.isDefined
6acd1a2bd146 clarified afp_pull_date: both repository versions are relevant;
wenzelm
parents: 66858
diff changeset
   732
      val rev2 = afp_rev.getOrElse("")
6acd1a2bd146 clarified afp_pull_date: both repository versions are relevant;
wenzelm
parents: 66858
diff changeset
   733
      val table = pull_date_table(afp)
6acd1a2bd146 clarified afp_pull_date: both repository versions are relevant;
wenzelm
parents: 66858
diff changeset
   734
77376
7ab9bac1ca96 tuned: prefer typed operations;
wenzelm
parents: 77375
diff changeset
   735
      val eq_rev = if_proper(rev, Prop.isabelle_version(table).equal(rev))
7ab9bac1ca96 tuned: prefer typed operations;
wenzelm
parents: 77375
diff changeset
   736
      val eq_rev2 = if_proper(rev2, Prop.afp_version(table).equal(rev2))
66863
6acd1a2bd146 clarified afp_pull_date: both repository versions are relevant;
wenzelm
parents: 66858
diff changeset
   737
65777
821e77ce41be tuned signature;
wenzelm
parents: 65775
diff changeset
   738
      SQL.Table("recent_pull_date", table.columns,
77381
a86e346b20d8 misc tuning and clarification: more uniform use of optional "sql" in SQL.Table.delete/select;
wenzelm
parents: 77376
diff changeset
   739
        table.select(table.columns, sql =
78153
55a6aa77f3d8 tuned signature: more operations;
wenzelm
parents: 77798
diff changeset
   740
          SQL.where_or(
78921
2fee5fba3116 proper default for disjunction (amending 9f7a94117666);
wenzelm
parents: 78900
diff changeset
   741
            recent(pull_date(afp)(table), days, default = SQL.TRUE),
78153
55a6aa77f3d8 tuned signature: more operations;
wenzelm
parents: 77798
diff changeset
   742
            SQL.and(eq_rev, eq_rev2))))
65702
7c6a91deb212 tuned signature;
wenzelm
parents: 65701
diff changeset
   743
    }
65694
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   744
78900
9f7a94117666 clarified "recent" time: days <= 0 means infinity (no constraint);
wenzelm
parents: 78894
diff changeset
   745
    def select_recent_log_names(days: Int = 0): PostgreSQL.Source = {
65781
6cd11999f3a3 tuned (again);
wenzelm
parents: 65779
diff changeset
   746
      val table1 = meta_info_table
78900
9f7a94117666 clarified "recent" time: days <= 0 means infinity (no constraint);
wenzelm
parents: 78894
diff changeset
   747
      val table2 = recent_pull_date_table(days = days)
77381
a86e346b20d8 misc tuning and clarification: more uniform use of optional "sql" in SQL.Table.delete/select;
wenzelm
parents: 77376
diff changeset
   748
      table1.select(List(log_name), distinct = true, sql =
a86e346b20d8 misc tuning and clarification: more uniform use of optional "sql" in SQL.Table.delete/select;
wenzelm
parents: 77376
diff changeset
   749
        SQL.join_inner + table2.query_named +
a86e346b20d8 misc tuning and clarification: more uniform use of optional "sql" in SQL.Table.delete/select;
wenzelm
parents: 77376
diff changeset
   750
        " ON " + Prop.isabelle_version(table1) + " = " + Prop.isabelle_version(table2))
65781
6cd11999f3a3 tuned (again);
wenzelm
parents: 65779
diff changeset
   751
    }
6cd11999f3a3 tuned (again);
wenzelm
parents: 65779
diff changeset
   752
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
   753
    def select_recent_versions(
78900
9f7a94117666 clarified "recent" time: days <= 0 means infinity (no constraint);
wenzelm
parents: 78894
diff changeset
   754
      days: Int = 0,
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
   755
      rev: String = "",
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
   756
      afp_rev: Option[String] = None,
75968
5a782ca6872b tuned signature: build_log db is specific to PostgreSQL;
wenzelm
parents: 75906
diff changeset
   757
      sql: PostgreSQL.Source = ""
5a782ca6872b tuned signature: build_log db is specific to PostgreSQL;
wenzelm
parents: 75906
diff changeset
   758
    ): PostgreSQL.Source = {
66880
486f4af28db9 more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents: 66874
diff changeset
   759
      val afp = afp_rev.isDefined
66858
2ca6f0275de7 support for AFP versions;
wenzelm
parents: 66857
diff changeset
   760
      val version = Prop.isabelle_version
78900
9f7a94117666 clarified "recent" time: days <= 0 means infinity (no constraint);
wenzelm
parents: 78894
diff changeset
   761
      val table1 = recent_pull_date_table(days = days, rev = rev, afp_rev = afp_rev)
65783
d3d5cb2d6866 pick isabelle_version based on build_log database;
wenzelm
parents: 65781
diff changeset
   762
      val table2 = meta_info_table
d3d5cb2d6866 pick isabelle_version based on build_log database;
wenzelm
parents: 65781
diff changeset
   763
      val aux_table = SQL.Table("aux", table2.columns, table2.select(sql = sql))
d3d5cb2d6866 pick isabelle_version based on build_log database;
wenzelm
parents: 65781
diff changeset
   764
d3d5cb2d6866 pick isabelle_version based on build_log database;
wenzelm
parents: 65781
diff changeset
   765
      val columns =
66858
2ca6f0275de7 support for AFP versions;
wenzelm
parents: 66857
diff changeset
   766
        table1.columns.map(c => c(table1)) :::
2ca6f0275de7 support for AFP versions;
wenzelm
parents: 66857
diff changeset
   767
          List(known.copy(expr = log_name(aux_table).defined))
65783
d3d5cb2d6866 pick isabelle_version based on build_log database;
wenzelm
parents: 65781
diff changeset
   768
      SQL.select(columns, distinct = true) +
d3d5cb2d6866 pick isabelle_version based on build_log database;
wenzelm
parents: 65781
diff changeset
   769
        table1.query_named + SQL.join_outer + aux_table.query_named +
66858
2ca6f0275de7 support for AFP versions;
wenzelm
parents: 66857
diff changeset
   770
        " ON " + version(table1) + " = " + version(aux_table) +
76870
c6cdf2a641f4 clarified signature: more explicit types;
wenzelm
parents: 76351
diff changeset
   771
        SQL.order_by(List(pull_date(afp)(table1)), descending = true)
65783
d3d5cb2d6866 pick isabelle_version based on build_log database;
wenzelm
parents: 65781
diff changeset
   772
    }
d3d5cb2d6866 pick isabelle_version based on build_log database;
wenzelm
parents: 65781
diff changeset
   773
65724
681cdf83ce09 clarified universal view: include pull_date;
wenzelm
parents: 65723
diff changeset
   774
681cdf83ce09 clarified universal view: include pull_date;
wenzelm
parents: 65723
diff changeset
   775
    /* universal view on main data */
681cdf83ce09 clarified universal view: include pull_date;
wenzelm
parents: 65723
diff changeset
   776
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
   777
    val universal_table: SQL.Table = {
66880
486f4af28db9 more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents: 66874
diff changeset
   778
      val afp_pull_date = pull_date(afp = true)
486f4af28db9 more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents: 66874
diff changeset
   779
      val version1 = Prop.isabelle_version
486f4af28db9 more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents: 66874
diff changeset
   780
      val version2 = Prop.afp_version
65724
681cdf83ce09 clarified universal view: include pull_date;
wenzelm
parents: 65723
diff changeset
   781
      val table1 = meta_info_table
66880
486f4af28db9 more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents: 66874
diff changeset
   782
      val table2 = pull_date_table(afp = true)
486f4af28db9 more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents: 66874
diff changeset
   783
      val table3 = pull_date_table()
65724
681cdf83ce09 clarified universal view: include pull_date;
wenzelm
parents: 65723
diff changeset
   784
66880
486f4af28db9 more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents: 66874
diff changeset
   785
      val a_columns = log_name :: afp_pull_date :: table1.columns.tail
65850
5414c14c3984 clarified universal table: include ml_statistics;
wenzelm
parents: 65804
diff changeset
   786
      val a_table =
5414c14c3984 clarified universal table: include ml_statistics;
wenzelm
parents: 65804
diff changeset
   787
        SQL.Table("a", a_columns,
66880
486f4af28db9 more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents: 66874
diff changeset
   788
          SQL.select(List(log_name, afp_pull_date) ::: table1.columns.tail.map(_.apply(table1))) +
77376
7ab9bac1ca96 tuned: prefer typed operations;
wenzelm
parents: 77375
diff changeset
   789
          table1 + SQL.join_outer + table2 + " ON " +
7ab9bac1ca96 tuned: prefer typed operations;
wenzelm
parents: 77375
diff changeset
   790
            SQL.and(
7ab9bac1ca96 tuned: prefer typed operations;
wenzelm
parents: 77375
diff changeset
   791
              version1(table1).ident + " = " + version1(table2).ident,
7ab9bac1ca96 tuned: prefer typed operations;
wenzelm
parents: 77375
diff changeset
   792
              version2(table1).ident + " = " + version2(table2).ident))
65724
681cdf83ce09 clarified universal view: include pull_date;
wenzelm
parents: 65723
diff changeset
   793
66880
486f4af28db9 more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents: 66874
diff changeset
   794
      val b_columns = log_name :: pull_date() :: a_columns.tail
65850
5414c14c3984 clarified universal table: include ml_statistics;
wenzelm
parents: 65804
diff changeset
   795
      val b_table =
5414c14c3984 clarified universal table: include ml_statistics;
wenzelm
parents: 65804
diff changeset
   796
        SQL.Table("b", b_columns,
66880
486f4af28db9 more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents: 66874
diff changeset
   797
          SQL.select(
486f4af28db9 more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents: 66874
diff changeset
   798
            List(log_name(a_table), pull_date()(table3)) ::: a_columns.tail.map(_.apply(a_table))) +
486f4af28db9 more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents: 66874
diff changeset
   799
          a_table.query_named + SQL.join_outer + table3 +
486f4af28db9 more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents: 66874
diff changeset
   800
          " ON " + version1(a_table) + " = " + version1(table3))
65850
5414c14c3984 clarified universal table: include ml_statistics;
wenzelm
parents: 65804
diff changeset
   801
66880
486f4af28db9 more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents: 66874
diff changeset
   802
      val c_columns = b_columns ::: sessions_table.columns.tail
486f4af28db9 more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents: 66874
diff changeset
   803
      val c_table =
486f4af28db9 more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents: 66874
diff changeset
   804
        SQL.Table("c", c_columns,
486f4af28db9 more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents: 66874
diff changeset
   805
          SQL.select(log_name(b_table) :: c_columns.tail) +
486f4af28db9 more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents: 66874
diff changeset
   806
          b_table.query_named + SQL.join_inner + sessions_table +
486f4af28db9 more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents: 66874
diff changeset
   807
          " ON " + log_name(b_table) + " = " + log_name(sessions_table))
486f4af28db9 more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents: 66874
diff changeset
   808
78266
d8c99a497502 clarified signature;
wenzelm
parents: 78187
diff changeset
   809
      make_table(c_columns ::: List(ml_statistics),
d8c99a497502 clarified signature;
wenzelm
parents: 78187
diff changeset
   810
        body =
66880
486f4af28db9 more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents: 66874
diff changeset
   811
          SQL.select(c_columns.map(_.apply(c_table)) ::: List(ml_statistics)) +
77376
7ab9bac1ca96 tuned: prefer typed operations;
wenzelm
parents: 77375
diff changeset
   812
          c_table.query_named + SQL.join_outer + ml_statistics_table + " ON " +
7ab9bac1ca96 tuned: prefer typed operations;
wenzelm
parents: 77375
diff changeset
   813
            SQL.and(
7ab9bac1ca96 tuned: prefer typed operations;
wenzelm
parents: 77375
diff changeset
   814
              log_name(c_table).ident + " = " + log_name(ml_statistics_table).ident,
78266
d8c99a497502 clarified signature;
wenzelm
parents: 78187
diff changeset
   815
              session_name(c_table).ident + " = " + session_name(ml_statistics_table).ident))
65724
681cdf83ce09 clarified universal view: include pull_date;
wenzelm
parents: 65723
diff changeset
   816
    }
65694
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   817
  }
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   818
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   819
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   820
  /* database access */
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   821
73031
f93f0597f4fb clarified signature: absorb XZ.Cache into XML.Cache;
wenzelm
parents: 73025
diff changeset
   822
  def store(options: Options, cache: XML.Cache = XML.Cache.make()): Store =
f93f0597f4fb clarified signature: absorb XZ.Cache into XML.Cache;
wenzelm
parents: 73025
diff changeset
   823
    new Store(options, cache)
65595
ffd8283b7be0 support for database connection;
wenzelm
parents: 65591
diff changeset
   824
78343
1932737e55a9 clarified signature: follow Store.open_database;
wenzelm
parents: 78266
diff changeset
   825
  class Store private[Build_Log](val options: Options, val cache: XML.Cache) {
77746
4855150bc98b tuned output;
wenzelm
parents: 77745
diff changeset
   826
    override def toString: String = {
4855150bc98b tuned output;
wenzelm
parents: 77745
diff changeset
   827
      val s =
78768
280a228dc2f1 prefer Exn.result: avoid accidental capture of interrupts, similar to ML;
wenzelm
parents: 78619
diff changeset
   828
        Exn.result { open_database() } match {
77746
4855150bc98b tuned output;
wenzelm
parents: 77745
diff changeset
   829
          case Exn.Res(db) =>
4855150bc98b tuned output;
wenzelm
parents: 77745
diff changeset
   830
            val db_name = db.toString
4855150bc98b tuned output;
wenzelm
parents: 77745
diff changeset
   831
            db.close()
4855150bc98b tuned output;
wenzelm
parents: 77745
diff changeset
   832
            "database = " + db_name
4855150bc98b tuned output;
wenzelm
parents: 77745
diff changeset
   833
          case Exn.Exn(_) => "no database"
4855150bc98b tuned output;
wenzelm
parents: 77745
diff changeset
   834
        }
4855150bc98b tuned output;
wenzelm
parents: 77745
diff changeset
   835
      "Store(" + s + ")"
4855150bc98b tuned output;
wenzelm
parents: 77745
diff changeset
   836
    }
4855150bc98b tuned output;
wenzelm
parents: 77745
diff changeset
   837
78347
72fc2ff08e07 clarified signature: more operations;
wenzelm
parents: 78343
diff changeset
   838
    def open_database(server: SSH.Server = SSH.no_server): PostgreSQL.Database =
72fc2ff08e07 clarified signature: more operations;
wenzelm
parents: 78343
diff changeset
   839
      PostgreSQL.open_database_server(options, server = server,
72fc2ff08e07 clarified signature: more operations;
wenzelm
parents: 78343
diff changeset
   840
        user = options.string("build_log_database_user"),
72fc2ff08e07 clarified signature: more operations;
wenzelm
parents: 78343
diff changeset
   841
        password = options.string("build_log_database_password"),
72fc2ff08e07 clarified signature: more operations;
wenzelm
parents: 78343
diff changeset
   842
        database = options.string("build_log_database_name"),
72fc2ff08e07 clarified signature: more operations;
wenzelm
parents: 78343
diff changeset
   843
        host = options.string("build_log_database_host"),
72fc2ff08e07 clarified signature: more operations;
wenzelm
parents: 78343
diff changeset
   844
        port = options.int("build_log_database_port"),
72fc2ff08e07 clarified signature: more operations;
wenzelm
parents: 78343
diff changeset
   845
        ssh_host = options.string("build_log_ssh_host"),
72fc2ff08e07 clarified signature: more operations;
wenzelm
parents: 78343
diff changeset
   846
        ssh_port = options.int("build_log_ssh_port"),
78863
f627ab8c276c discontinued pointless option (reverting 63d55ba90a9f): performance tuning works better via SQL.Database.execute_batch_statement;
wenzelm
parents: 78862
diff changeset
   847
        ssh_user = options.string("build_log_ssh_user"))
65599
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   848
78851
db37cae970a6 more robust init_database();
wenzelm
parents: 78850
diff changeset
   849
    def init_database(db: SQL.Database, minimal: Boolean = false): Unit =
db37cae970a6 more robust init_database();
wenzelm
parents: 78850
diff changeset
   850
      private_data.transaction_lock(db, create = true, label = "build_log_init") {
db37cae970a6 more robust init_database();
wenzelm
parents: 78850
diff changeset
   851
        if (!minimal) {
db37cae970a6 more robust init_database();
wenzelm
parents: 78850
diff changeset
   852
          db.create_view(private_data.pull_date_table())
db37cae970a6 more robust init_database();
wenzelm
parents: 78850
diff changeset
   853
          db.create_view(private_data.pull_date_table(afp = true))
db37cae970a6 more robust init_database();
wenzelm
parents: 78850
diff changeset
   854
        }
db37cae970a6 more robust init_database();
wenzelm
parents: 78850
diff changeset
   855
        db.create_view(private_data.universal_table)
db37cae970a6 more robust init_database();
wenzelm
parents: 78850
diff changeset
   856
      }
db37cae970a6 more robust init_database();
wenzelm
parents: 78850
diff changeset
   857
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
   858
    def snapshot_database(
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
   859
      db: PostgreSQL.Database,
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
   860
      sqlite_database: Path,
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
   861
      days: Int = 100,
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
   862
      ml_statistics: Boolean = false
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
   863
    ): Unit = {
72375
e48d93811ed7 clarified signature;
wenzelm
parents: 72012
diff changeset
   864
      Isabelle_System.make_directory(sqlite_database.dir)
65694
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   865
      sqlite_database.file.delete
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   866
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   867
      using(SQLite.open_database(sqlite_database)) { db2 =>
65694
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   868
        db.transaction {
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   869
          db2.transaction {
65705
d0ca2a3ea657 more snapshot content;
wenzelm
parents: 65703
diff changeset
   870
            // main content
78849
df162316b6a7 clarified names;
wenzelm
parents: 78843
diff changeset
   871
            db2.create_table(private_data.meta_info_table)
df162316b6a7 clarified names;
wenzelm
parents: 78843
diff changeset
   872
            db2.create_table(private_data.sessions_table)
df162316b6a7 clarified names;
wenzelm
parents: 78843
diff changeset
   873
            db2.create_table(private_data.theories_table)
df162316b6a7 clarified names;
wenzelm
parents: 78843
diff changeset
   874
            db2.create_table(private_data.ml_statistics_table)
65705
d0ca2a3ea657 more snapshot content;
wenzelm
parents: 65703
diff changeset
   875
d0ca2a3ea657 more snapshot content;
wenzelm
parents: 65703
diff changeset
   876
            val recent_log_names =
77552
080422b3d914 clarified signature: reduce boilerplate;
wenzelm
parents: 77551
diff changeset
   877
              db.execute_query_statement(
78900
9f7a94117666 clarified "recent" time: days <= 0 means infinity (no constraint);
wenzelm
parents: 78894
diff changeset
   878
                private_data.select_recent_log_names(days = days),
78849
df162316b6a7 clarified names;
wenzelm
parents: 78843
diff changeset
   879
                List.from[String], res => res.string(private_data.log_name))
65705
d0ca2a3ea657 more snapshot content;
wenzelm
parents: 65703
diff changeset
   880
d0ca2a3ea657 more snapshot content;
wenzelm
parents: 65703
diff changeset
   881
            for (log_name <- recent_log_names) {
d0ca2a3ea657 more snapshot content;
wenzelm
parents: 65703
diff changeset
   882
              read_meta_info(db, log_name).foreach(meta_info =>
d0ca2a3ea657 more snapshot content;
wenzelm
parents: 65703
diff changeset
   883
                update_meta_info(db2, log_name, meta_info))
d0ca2a3ea657 more snapshot content;
wenzelm
parents: 65703
diff changeset
   884
d0ca2a3ea657 more snapshot content;
wenzelm
parents: 65703
diff changeset
   885
              update_sessions(db2, log_name, read_build_info(db, log_name))
d0ca2a3ea657 more snapshot content;
wenzelm
parents: 65703
diff changeset
   886
65856
69f4dacd31cf proper ml_statistics;
wenzelm
parents: 65853
diff changeset
   887
              if (ml_statistics) {
69f4dacd31cf proper ml_statistics;
wenzelm
parents: 65853
diff changeset
   888
                update_ml_statistics(db2, log_name,
69f4dacd31cf proper ml_statistics;
wenzelm
parents: 65853
diff changeset
   889
                  read_build_info(db, log_name, ml_statistics = true))
69f4dacd31cf proper ml_statistics;
wenzelm
parents: 65853
diff changeset
   890
              }
65705
d0ca2a3ea657 more snapshot content;
wenzelm
parents: 65703
diff changeset
   891
            }
d0ca2a3ea657 more snapshot content;
wenzelm
parents: 65703
diff changeset
   892
d0ca2a3ea657 more snapshot content;
wenzelm
parents: 65703
diff changeset
   893
            // pull_date
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
   894
            for (afp <- List(false, true)) {
66880
486f4af28db9 more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents: 66874
diff changeset
   895
              val afp_rev = if (afp) Some("") else None
78849
df162316b6a7 clarified names;
wenzelm
parents: 78843
diff changeset
   896
              val table = private_data.pull_date_table(afp)
65694
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   897
              db2.create_table(table)
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   898
              db2.using_statement(table.insert()) { stmt2 =>
66880
486f4af28db9 more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents: 66874
diff changeset
   899
                db.using_statement(
78900
9f7a94117666 clarified "recent" time: days <= 0 means infinity (no constraint);
wenzelm
parents: 78894
diff changeset
   900
                  private_data.recent_pull_date_table(days = days, afp_rev = afp_rev).query) { stmt =>
78352
10f8f12c61b0 proper close() operation;
wenzelm
parents: 78347
diff changeset
   901
                  using(stmt.execute_query()) { res =>
10f8f12c61b0 proper close() operation;
wenzelm
parents: 78347
diff changeset
   902
                    while (res.next()) {
10f8f12c61b0 proper close() operation;
wenzelm
parents: 78347
diff changeset
   903
                      for ((c, i) <- table.columns.zipWithIndex) {
10f8f12c61b0 proper close() operation;
wenzelm
parents: 78347
diff changeset
   904
                        stmt2.string(i + 1) = res.get_string(c)
10f8f12c61b0 proper close() operation;
wenzelm
parents: 78347
diff changeset
   905
                      }
10f8f12c61b0 proper close() operation;
wenzelm
parents: 78347
diff changeset
   906
                      stmt2.execute()
65748
1f4a80e80c88 tuned signature;
wenzelm
parents: 65741
diff changeset
   907
                    }
65694
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   908
                  }
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   909
                }
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   910
              }
65709
1626b73daccf eliminated unused afp_pull_date table;
wenzelm
parents: 65708
diff changeset
   911
            }
65705
d0ca2a3ea657 more snapshot content;
wenzelm
parents: 65703
diff changeset
   912
d0ca2a3ea657 more snapshot content;
wenzelm
parents: 65703
diff changeset
   913
            // full view
78849
df162316b6a7 clarified names;
wenzelm
parents: 78843
diff changeset
   914
            db2.create_view(private_data.universal_table)
65694
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   915
          }
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   916
        }
77664
f5d3ade80d15 more specific vacuum operation, which is also relevant to PostgreSQL;
wenzelm
parents: 77552
diff changeset
   917
        db2.vacuum()
75394
42267c650205 tuned formatting;
wenzelm
parents: 75393
diff changeset
   918
      }
65694
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   919
    }
b82f2990161a clarified modules;
wenzelm
parents: 65693
diff changeset
   920
78859
aeb511a520f4 performance tuning: more careful database access;
wenzelm
parents: 78858
diff changeset
   921
    def read_domain(
aeb511a520f4 performance tuning: more careful database access;
wenzelm
parents: 78858
diff changeset
   922
      db: SQL.Database,
aeb511a520f4 performance tuning: more careful database access;
wenzelm
parents: 78858
diff changeset
   923
      table: SQL.Table,
aeb511a520f4 performance tuning: more careful database access;
wenzelm
parents: 78858
diff changeset
   924
      column: SQL.Column,
aeb511a520f4 performance tuning: more careful database access;
wenzelm
parents: 78858
diff changeset
   925
      restriction: Option[Iterable[String]] = None
aeb511a520f4 performance tuning: more careful database access;
wenzelm
parents: 78858
diff changeset
   926
    ): Set[String] = {
aeb511a520f4 performance tuning: more careful database access;
wenzelm
parents: 78858
diff changeset
   927
      private_data.transaction_lock(db, label = "Build_Log.read_domain") {
aeb511a520f4 performance tuning: more careful database access;
wenzelm
parents: 78858
diff changeset
   928
        db.execute_query_statement(
aeb511a520f4 performance tuning: more careful database access;
wenzelm
parents: 78858
diff changeset
   929
          table.select(List(column),
aeb511a520f4 performance tuning: more careful database access;
wenzelm
parents: 78858
diff changeset
   930
            sql = restriction match {
aeb511a520f4 performance tuning: more careful database access;
wenzelm
parents: 78858
diff changeset
   931
              case None => ""
aeb511a520f4 performance tuning: more careful database access;
wenzelm
parents: 78858
diff changeset
   932
              case Some(names) => column.where_member(names)
aeb511a520f4 performance tuning: more careful database access;
wenzelm
parents: 78858
diff changeset
   933
            },
aeb511a520f4 performance tuning: more careful database access;
wenzelm
parents: 78858
diff changeset
   934
            distinct = true),
aeb511a520f4 performance tuning: more careful database access;
wenzelm
parents: 78858
diff changeset
   935
          Set.from[String], res => cache.string(res.string(column)))
aeb511a520f4 performance tuning: more careful database access;
wenzelm
parents: 78858
diff changeset
   936
      }
aeb511a520f4 performance tuning: more careful database access;
wenzelm
parents: 78858
diff changeset
   937
    }
65688
wenzelm
parents: 65685
diff changeset
   938
77543
97b5547f2b17 tuned whitespace and braces;
wenzelm
parents: 77541
diff changeset
   939
    def update_meta_info(db: SQL.Database, log_name: String, meta_info: Meta_Info): Unit =
78850
3069da1743bc proper private_data.transaction_lock;
wenzelm
parents: 78849
diff changeset
   940
      db.execute_statement(db.insert_permissive(private_data.meta_info_table),
3069da1743bc proper private_data.transaction_lock;
wenzelm
parents: 78849
diff changeset
   941
        { stmt =>
3069da1743bc proper private_data.transaction_lock;
wenzelm
parents: 78849
diff changeset
   942
          stmt.string(1) = log_name
3069da1743bc proper private_data.transaction_lock;
wenzelm
parents: 78849
diff changeset
   943
          for ((c, i) <- private_data.meta_info_table.columns.tail.zipWithIndex) {
3069da1743bc proper private_data.transaction_lock;
wenzelm
parents: 78849
diff changeset
   944
            if (c.T == SQL.Type.Date) stmt.date(i + 2) = meta_info.get_date(c)
3069da1743bc proper private_data.transaction_lock;
wenzelm
parents: 78849
diff changeset
   945
            else stmt.string(i + 2) = meta_info.get(c)
3069da1743bc proper private_data.transaction_lock;
wenzelm
parents: 78849
diff changeset
   946
          }
77798
28c930aefb28 proper stmt.execute() within loop (amending 9d9b30741fc4);
wenzelm
parents: 77752
diff changeset
   947
        }
78850
3069da1743bc proper private_data.transaction_lock;
wenzelm
parents: 78849
diff changeset
   948
      )
65600
138ffa41dc54 clarified filter_files: sorted and unique;
wenzelm
parents: 65599
diff changeset
   949
78850
3069da1743bc proper private_data.transaction_lock;
wenzelm
parents: 78849
diff changeset
   950
    def update_sessions(db: SQL.Database, log_name: String, build_info: Build_Info): Unit = {
3069da1743bc proper private_data.transaction_lock;
wenzelm
parents: 78849
diff changeset
   951
      val sessions =
3069da1743bc proper private_data.transaction_lock;
wenzelm
parents: 78849
diff changeset
   952
        if (build_info.sessions.isEmpty) Build_Info.sessions_dummy
3069da1743bc proper private_data.transaction_lock;
wenzelm
parents: 78849
diff changeset
   953
        else build_info.sessions
3069da1743bc proper private_data.transaction_lock;
wenzelm
parents: 78849
diff changeset
   954
      db.execute_batch_statement(db.insert_permissive(private_data.sessions_table),
3069da1743bc proper private_data.transaction_lock;
wenzelm
parents: 78849
diff changeset
   955
        for ((session_name, session) <- sessions) yield { (stmt: SQL.Statement) =>
77798
28c930aefb28 proper stmt.execute() within loop (amending 9d9b30741fc4);
wenzelm
parents: 77752
diff changeset
   956
          stmt.string(1) = log_name
28c930aefb28 proper stmt.execute() within loop (amending 9d9b30741fc4);
wenzelm
parents: 77752
diff changeset
   957
          stmt.string(2) = session_name
28c930aefb28 proper stmt.execute() within loop (amending 9d9b30741fc4);
wenzelm
parents: 77752
diff changeset
   958
          stmt.string(3) = proper_string(session.chapter)
28c930aefb28 proper stmt.execute() within loop (amending 9d9b30741fc4);
wenzelm
parents: 77752
diff changeset
   959
          stmt.string(4) = session.proper_groups
78836
dd350a41594c defined statically known tables of Build_Log;
Fabian Huch <huch@in.tum.de>
parents: 78768
diff changeset
   960
          stmt.string(5) = session.hostname
dd350a41594c defined statically known tables of Build_Log;
Fabian Huch <huch@in.tum.de>
parents: 78768
diff changeset
   961
          stmt.int(6) = session.threads
dd350a41594c defined statically known tables of Build_Log;
Fabian Huch <huch@in.tum.de>
parents: 78768
diff changeset
   962
          stmt.long(7) = session.timing.elapsed.proper_ms
dd350a41594c defined statically known tables of Build_Log;
Fabian Huch <huch@in.tum.de>
parents: 78768
diff changeset
   963
          stmt.long(8) = session.timing.cpu.proper_ms
dd350a41594c defined statically known tables of Build_Log;
Fabian Huch <huch@in.tum.de>
parents: 78768
diff changeset
   964
          stmt.long(9) = session.timing.gc.proper_ms
dd350a41594c defined statically known tables of Build_Log;
Fabian Huch <huch@in.tum.de>
parents: 78768
diff changeset
   965
          stmt.double(10) = session.timing.factor
dd350a41594c defined statically known tables of Build_Log;
Fabian Huch <huch@in.tum.de>
parents: 78768
diff changeset
   966
          stmt.long(11) = session.ml_timing.elapsed.proper_ms
dd350a41594c defined statically known tables of Build_Log;
Fabian Huch <huch@in.tum.de>
parents: 78768
diff changeset
   967
          stmt.long(12) = session.ml_timing.cpu.proper_ms
dd350a41594c defined statically known tables of Build_Log;
Fabian Huch <huch@in.tum.de>
parents: 78768
diff changeset
   968
          stmt.long(13) = session.ml_timing.gc.proper_ms
dd350a41594c defined statically known tables of Build_Log;
Fabian Huch <huch@in.tum.de>
parents: 78768
diff changeset
   969
          stmt.double(14) = session.ml_timing.factor
dd350a41594c defined statically known tables of Build_Log;
Fabian Huch <huch@in.tum.de>
parents: 78768
diff changeset
   970
          stmt.long(15) = session.heap_size.map(_.bytes)
dd350a41594c defined statically known tables of Build_Log;
Fabian Huch <huch@in.tum.de>
parents: 78768
diff changeset
   971
          stmt.string(16) = session.status.map(_.toString)
dd350a41594c defined statically known tables of Build_Log;
Fabian Huch <huch@in.tum.de>
parents: 78768
diff changeset
   972
          stmt.bytes(17) = compress_errors(session.errors, cache = cache.compress)
dd350a41594c defined statically known tables of Build_Log;
Fabian Huch <huch@in.tum.de>
parents: 78768
diff changeset
   973
          stmt.string(18) = session.sources
77798
28c930aefb28 proper stmt.execute() within loop (amending 9d9b30741fc4);
wenzelm
parents: 77752
diff changeset
   974
        }
78850
3069da1743bc proper private_data.transaction_lock;
wenzelm
parents: 78849
diff changeset
   975
      )
3069da1743bc proper private_data.transaction_lock;
wenzelm
parents: 78849
diff changeset
   976
    }
65642
1423cbbc542d clarified database update operations;
wenzelm
parents: 65639
diff changeset
   977
78850
3069da1743bc proper private_data.transaction_lock;
wenzelm
parents: 78849
diff changeset
   978
    def update_theories(db: SQL.Database, log_name: String, build_info: Build_Info): Unit = {
3069da1743bc proper private_data.transaction_lock;
wenzelm
parents: 78849
diff changeset
   979
      val sessions =
3069da1743bc proper private_data.transaction_lock;
wenzelm
parents: 78849
diff changeset
   980
        if (build_info.sessions.forall({ case (_, session) => session.theory_timings.isEmpty }))
3069da1743bc proper private_data.transaction_lock;
wenzelm
parents: 78849
diff changeset
   981
          Build_Info.sessions_dummy
3069da1743bc proper private_data.transaction_lock;
wenzelm
parents: 78849
diff changeset
   982
        else build_info.sessions
3069da1743bc proper private_data.transaction_lock;
wenzelm
parents: 78849
diff changeset
   983
      db.execute_batch_statement(db.insert_permissive(private_data.theories_table),
77798
28c930aefb28 proper stmt.execute() within loop (amending 9d9b30741fc4);
wenzelm
parents: 77752
diff changeset
   984
        for {
28c930aefb28 proper stmt.execute() within loop (amending 9d9b30741fc4);
wenzelm
parents: 77752
diff changeset
   985
          (session_name, session) <- sessions
28c930aefb28 proper stmt.execute() within loop (amending 9d9b30741fc4);
wenzelm
parents: 77752
diff changeset
   986
          (theory_name, timing) <- session.theory_timings
78850
3069da1743bc proper private_data.transaction_lock;
wenzelm
parents: 78849
diff changeset
   987
        } yield { (stmt: SQL.Statement) =>
77798
28c930aefb28 proper stmt.execute() within loop (amending 9d9b30741fc4);
wenzelm
parents: 77752
diff changeset
   988
          stmt.string(1) = log_name
28c930aefb28 proper stmt.execute() within loop (amending 9d9b30741fc4);
wenzelm
parents: 77752
diff changeset
   989
          stmt.string(2) = session_name
28c930aefb28 proper stmt.execute() within loop (amending 9d9b30741fc4);
wenzelm
parents: 77752
diff changeset
   990
          stmt.string(3) = theory_name
28c930aefb28 proper stmt.execute() within loop (amending 9d9b30741fc4);
wenzelm
parents: 77752
diff changeset
   991
          stmt.long(4) = timing.elapsed.ms
28c930aefb28 proper stmt.execute() within loop (amending 9d9b30741fc4);
wenzelm
parents: 77752
diff changeset
   992
          stmt.long(5) = timing.cpu.ms
28c930aefb28 proper stmt.execute() within loop (amending 9d9b30741fc4);
wenzelm
parents: 77752
diff changeset
   993
          stmt.long(6) = timing.gc.ms
28c930aefb28 proper stmt.execute() within loop (amending 9d9b30741fc4);
wenzelm
parents: 77752
diff changeset
   994
        }
78850
3069da1743bc proper private_data.transaction_lock;
wenzelm
parents: 78849
diff changeset
   995
      )
3069da1743bc proper private_data.transaction_lock;
wenzelm
parents: 78849
diff changeset
   996
    }
66874
0b8da0fc9563 store theory timings in session in build_log database;
wenzelm
parents: 66873
diff changeset
   997
78850
3069da1743bc proper private_data.transaction_lock;
wenzelm
parents: 78849
diff changeset
   998
    def update_ml_statistics(db: SQL.Database, log_name: String, build_info: Build_Info): Unit = {
3069da1743bc proper private_data.transaction_lock;
wenzelm
parents: 78849
diff changeset
   999
      val ml_stats: List[(String, Option[Bytes])] =
3069da1743bc proper private_data.transaction_lock;
wenzelm
parents: 78849
diff changeset
  1000
        Par_List.map[(String, Session_Entry), (String, Option[Bytes])](
3069da1743bc proper private_data.transaction_lock;
wenzelm
parents: 78849
diff changeset
  1001
          { case (a, b) => (a, Properties.compress(b.ml_statistics, cache = cache.compress).proper) },
3069da1743bc proper private_data.transaction_lock;
wenzelm
parents: 78849
diff changeset
  1002
          build_info.sessions.iterator.filter(p => p._2.ml_statistics.nonEmpty).toList)
3069da1743bc proper private_data.transaction_lock;
wenzelm
parents: 78849
diff changeset
  1003
      val entries = if (ml_stats.nonEmpty) ml_stats else List("" -> None)
3069da1743bc proper private_data.transaction_lock;
wenzelm
parents: 78849
diff changeset
  1004
      db.execute_batch_statement(db.insert_permissive(private_data.ml_statistics_table),
3069da1743bc proper private_data.transaction_lock;
wenzelm
parents: 78849
diff changeset
  1005
        for ((session_name, ml_statistics) <- entries) yield { (stmt: SQL.Statement) =>
77798
28c930aefb28 proper stmt.execute() within loop (amending 9d9b30741fc4);
wenzelm
parents: 77752
diff changeset
  1006
          stmt.string(1) = log_name
28c930aefb28 proper stmt.execute() within loop (amending 9d9b30741fc4);
wenzelm
parents: 77752
diff changeset
  1007
          stmt.string(2) = session_name
28c930aefb28 proper stmt.execute() within loop (amending 9d9b30741fc4);
wenzelm
parents: 77752
diff changeset
  1008
          stmt.bytes(3) = ml_statistics
28c930aefb28 proper stmt.execute() within loop (amending 9d9b30741fc4);
wenzelm
parents: 77752
diff changeset
  1009
        }
78850
3069da1743bc proper private_data.transaction_lock;
wenzelm
parents: 78849
diff changeset
  1010
      )
3069da1743bc proper private_data.transaction_lock;
wenzelm
parents: 78849
diff changeset
  1011
    }
65645
2c704ae04db1 clarified database layout: bulky ml_statistics are stored/retrieved separately;
wenzelm
parents: 65643
diff changeset
  1012
77748
5a2a297a91f8 more robust errors: proceed updating database;
wenzelm
parents: 77747
diff changeset
  1013
    def write_info(db: SQL.Database, files: List[JFile],
5a2a297a91f8 more robust errors: proceed updating database;
wenzelm
parents: 77747
diff changeset
  1014
      ml_statistics: Boolean = false,
5a2a297a91f8 more robust errors: proceed updating database;
wenzelm
parents: 77747
diff changeset
  1015
      progress: Progress = new Progress,
5a2a297a91f8 more robust errors: proceed updating database;
wenzelm
parents: 77747
diff changeset
  1016
      errors: Multi_Map[String, String] = Multi_Map.empty
5a2a297a91f8 more robust errors: proceed updating database;
wenzelm
parents: 77747
diff changeset
  1017
    ): Multi_Map[String, String] = {
78851
db37cae970a6 more robust init_database();
wenzelm
parents: 78850
diff changeset
  1018
      init_database(db)
db37cae970a6 more robust init_database();
wenzelm
parents: 78850
diff changeset
  1019
78866
1bd52b048f8e more parallelism via consumer thread: with mailbox limit to avoid ressource problems;
wenzelm
parents: 78863
diff changeset
  1020
      val errors_result = Synchronized(errors)
1bd52b048f8e more parallelism via consumer thread: with mailbox limit to avoid ressource problems;
wenzelm
parents: 78863
diff changeset
  1021
      def add_error(name: String, exn: Throwable): Unit =
1bd52b048f8e more parallelism via consumer thread: with mailbox limit to avoid ressource problems;
wenzelm
parents: 78863
diff changeset
  1022
        errors_result.change(_.insert(name, Exn.print(exn)))
77748
5a2a297a91f8 more robust errors: proceed updating database;
wenzelm
parents: 77747
diff changeset
  1023
78859
aeb511a520f4 performance tuning: more careful database access;
wenzelm
parents: 78858
diff changeset
  1024
      val files_domain = {
aeb511a520f4 performance tuning: more careful database access;
wenzelm
parents: 78858
diff changeset
  1025
        val names = files.map(Log_File.plain_name).toSet
aeb511a520f4 performance tuning: more careful database access;
wenzelm
parents: 78858
diff changeset
  1026
        if (names.size > 100) None else Some(names)
aeb511a520f4 performance tuning: more careful database access;
wenzelm
parents: 78858
diff changeset
  1027
      }
aeb511a520f4 performance tuning: more careful database access;
wenzelm
parents: 78858
diff changeset
  1028
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
  1029
      abstract class Table_Status(table: SQL.Table) {
78866
1bd52b048f8e more parallelism via consumer thread: with mailbox limit to avoid ressource problems;
wenzelm
parents: 78863
diff changeset
  1030
        private val known =
1bd52b048f8e more parallelism via consumer thread: with mailbox limit to avoid ressource problems;
wenzelm
parents: 78863
diff changeset
  1031
          Synchronized(read_domain(db, table, private_data.log_name, restriction = files_domain))
65688
wenzelm
parents: 65685
diff changeset
  1032
78866
1bd52b048f8e more parallelism via consumer thread: with mailbox limit to avoid ressource problems;
wenzelm
parents: 78863
diff changeset
  1033
        def required(file: JFile): Boolean = !(known.value)(Log_File.plain_name(file))
1bd52b048f8e more parallelism via consumer thread: with mailbox limit to avoid ressource problems;
wenzelm
parents: 78863
diff changeset
  1034
        def required(log_file: Log_File): Boolean = !(known.value)(log_file.name)
65705
d0ca2a3ea657 more snapshot content;
wenzelm
parents: 65703
diff changeset
  1035
d0ca2a3ea657 more snapshot content;
wenzelm
parents: 65703
diff changeset
  1036
        def update_db(db: SQL.Database, log_file: Log_File): Unit
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
  1037
        def update(log_file: Log_File): Unit = {
77748
5a2a297a91f8 more robust errors: proceed updating database;
wenzelm
parents: 77747
diff changeset
  1038
          if (required(log_file)) {
65642
1423cbbc542d clarified database update operations;
wenzelm
parents: 65639
diff changeset
  1039
            update_db(db, log_file)
78866
1bd52b048f8e more parallelism via consumer thread: with mailbox limit to avoid ressource problems;
wenzelm
parents: 78863
diff changeset
  1040
            known.change(_ + log_file.name)
65618
986fac3c60b4 tuned transaction granularity;
wenzelm
parents: 65616
diff changeset
  1041
          }
65614
325801edb37d clarified transaction boundaries: more robust incremental write operations;
wenzelm
parents: 65613
diff changeset
  1042
        }
65605
a6447eb6bc38 separate small meta_info vs. big build_info;
wenzelm
parents: 65603
diff changeset
  1043
      }
78859
aeb511a520f4 performance tuning: more careful database access;
wenzelm
parents: 78858
diff changeset
  1044
aeb511a520f4 performance tuning: more careful database access;
wenzelm
parents: 78858
diff changeset
  1045
      val ml_statistics_status =
78984
417b490c9b89 proper ml_statistics (amending aeb511a520f4);
wenzelm
parents: 78921
diff changeset
  1046
        if (ml_statistics) {
78859
aeb511a520f4 performance tuning: more careful database access;
wenzelm
parents: 78858
diff changeset
  1047
          List(
aeb511a520f4 performance tuning: more careful database access;
wenzelm
parents: 78858
diff changeset
  1048
            new Table_Status(private_data.ml_statistics_table) {
aeb511a520f4 performance tuning: more careful database access;
wenzelm
parents: 78858
diff changeset
  1049
              override def update_db(db: SQL.Database, log_file: Log_File): Unit =
aeb511a520f4 performance tuning: more careful database access;
wenzelm
parents: 78858
diff changeset
  1050
                update_ml_statistics(db, log_file.name,
aeb511a520f4 performance tuning: more careful database access;
wenzelm
parents: 78858
diff changeset
  1051
                  log_file.parse_build_info(ml_statistics = true))
aeb511a520f4 performance tuning: more careful database access;
wenzelm
parents: 78858
diff changeset
  1052
            })
aeb511a520f4 performance tuning: more careful database access;
wenzelm
parents: 78858
diff changeset
  1053
        }
78984
417b490c9b89 proper ml_statistics (amending aeb511a520f4);
wenzelm
parents: 78921
diff changeset
  1054
        else Nil
65642
1423cbbc542d clarified database update operations;
wenzelm
parents: 65639
diff changeset
  1055
      val status =
1423cbbc542d clarified database update operations;
wenzelm
parents: 65639
diff changeset
  1056
        List(
78849
df162316b6a7 clarified names;
wenzelm
parents: 78843
diff changeset
  1057
          new Table_Status(private_data.meta_info_table) {
65705
d0ca2a3ea657 more snapshot content;
wenzelm
parents: 65703
diff changeset
  1058
            override def update_db(db: SQL.Database, log_file: Log_File): Unit =
d0ca2a3ea657 more snapshot content;
wenzelm
parents: 65703
diff changeset
  1059
              update_meta_info(db, log_file.name, log_file.parse_meta_info())
d0ca2a3ea657 more snapshot content;
wenzelm
parents: 65703
diff changeset
  1060
          },
78849
df162316b6a7 clarified names;
wenzelm
parents: 78843
diff changeset
  1061
          new Table_Status(private_data.sessions_table) {
65705
d0ca2a3ea657 more snapshot content;
wenzelm
parents: 65703
diff changeset
  1062
            override def update_db(db: SQL.Database, log_file: Log_File): Unit =
d0ca2a3ea657 more snapshot content;
wenzelm
parents: 65703
diff changeset
  1063
              update_sessions(db, log_file.name, log_file.parse_build_info())
d0ca2a3ea657 more snapshot content;
wenzelm
parents: 65703
diff changeset
  1064
          },
78849
df162316b6a7 clarified names;
wenzelm
parents: 78843
diff changeset
  1065
          new Table_Status(private_data.theories_table) {
66874
0b8da0fc9563 store theory timings in session in build_log database;
wenzelm
parents: 66873
diff changeset
  1066
            override def update_db(db: SQL.Database, log_file: Log_File): Unit =
0b8da0fc9563 store theory timings in session in build_log database;
wenzelm
parents: 66873
diff changeset
  1067
              update_theories(db, log_file.name, log_file.parse_build_info())
78859
aeb511a520f4 performance tuning: more careful database access;
wenzelm
parents: 78858
diff changeset
  1068
          }
aeb511a520f4 performance tuning: more careful database access;
wenzelm
parents: 78858
diff changeset
  1069
        ) ::: ml_statistics_status
65642
1423cbbc542d clarified database update operations;
wenzelm
parents: 65639
diff changeset
  1070
78866
1bd52b048f8e more parallelism via consumer thread: with mailbox limit to avoid ressource problems;
wenzelm
parents: 78863
diff changeset
  1071
      val consumer =
1bd52b048f8e more parallelism via consumer thread: with mailbox limit to avoid ressource problems;
wenzelm
parents: 78863
diff changeset
  1072
        Consumer_Thread.fork[Log_File]("build_log_database")(
78880
9ce8bf038444 tuned whitespace;
wenzelm
parents: 78879
diff changeset
  1073
          limit = 1,
78866
1bd52b048f8e more parallelism via consumer thread: with mailbox limit to avoid ressource problems;
wenzelm
parents: 78863
diff changeset
  1074
          consume = { log_file =>
78877
45d570945fe4 more detailed progress for build_log_database, to see better what happens when;
wenzelm
parents: 78875
diff changeset
  1075
            val t0 = progress.start.time
45d570945fe4 more detailed progress for build_log_database, to see better what happens when;
wenzelm
parents: 78875
diff changeset
  1076
            val t1 = progress.now().time
45d570945fe4 more detailed progress for build_log_database, to see better what happens when;
wenzelm
parents: 78875
diff changeset
  1077
78862
cc8391b92747 clarified database transactions (see also 2c704ae04db1, 7bd0a250183b);
wenzelm
parents: 78859
diff changeset
  1078
            private_data.transaction_lock(db, label = "build_log_database") {
cc8391b92747 clarified database transactions (see also 2c704ae04db1, 7bd0a250183b);
wenzelm
parents: 78859
diff changeset
  1079
              try { status.foreach(_.update(log_file)) }
78866
1bd52b048f8e more parallelism via consumer thread: with mailbox limit to avoid ressource problems;
wenzelm
parents: 78863
diff changeset
  1080
              catch { case exn: Throwable => add_error(log_file.name, exn) }
78862
cc8391b92747 clarified database transactions (see also 2c704ae04db1, 7bd0a250183b);
wenzelm
parents: 78859
diff changeset
  1081
            }
78877
45d570945fe4 more detailed progress for build_log_database, to see better what happens when;
wenzelm
parents: 78875
diff changeset
  1082
45d570945fe4 more detailed progress for build_log_database, to see better what happens when;
wenzelm
parents: 78875
diff changeset
  1083
            val t2 = progress.now().time
45d570945fe4 more detailed progress for build_log_database, to see better what happens when;
wenzelm
parents: 78875
diff changeset
  1084
78880
9ce8bf038444 tuned whitespace;
wenzelm
parents: 78879
diff changeset
  1085
            progress.echo(verbose = true, msg =
9ce8bf038444 tuned whitespace;
wenzelm
parents: 78879
diff changeset
  1086
              "Log " + quote(log_file.name) + " (" +
9ce8bf038444 tuned whitespace;
wenzelm
parents: 78879
diff changeset
  1087
                (t1 - t0).message_hms + " start time, " +
9ce8bf038444 tuned whitespace;
wenzelm
parents: 78879
diff changeset
  1088
                (t2 - t1).message + " elapsed time)")
78877
45d570945fe4 more detailed progress for build_log_database, to see better what happens when;
wenzelm
parents: 78875
diff changeset
  1089
78866
1bd52b048f8e more parallelism via consumer thread: with mailbox limit to avoid ressource problems;
wenzelm
parents: 78863
diff changeset
  1090
            true
78880
9ce8bf038444 tuned whitespace;
wenzelm
parents: 78879
diff changeset
  1091
          })
78866
1bd52b048f8e more parallelism via consumer thread: with mailbox limit to avoid ressource problems;
wenzelm
parents: 78863
diff changeset
  1092
1bd52b048f8e more parallelism via consumer thread: with mailbox limit to avoid ressource problems;
wenzelm
parents: 78863
diff changeset
  1093
      try {
1bd52b048f8e more parallelism via consumer thread: with mailbox limit to avoid ressource problems;
wenzelm
parents: 78863
diff changeset
  1094
        for (file <- files.iterator if status.exists(_.required(file))) {
78985
24e686fe043e clarified Log_File.cache: reuse existing Store.cache / Build_Log.Store.cache;
wenzelm
parents: 78984
diff changeset
  1095
          Exn.result { Log_File.read(file, cache = cache) } match {
78866
1bd52b048f8e more parallelism via consumer thread: with mailbox limit to avoid ressource problems;
wenzelm
parents: 78863
diff changeset
  1096
            case Exn.Res(log_file) => consumer.send(log_file)
78877
45d570945fe4 more detailed progress for build_log_database, to see better what happens when;
wenzelm
parents: 78875
diff changeset
  1097
            case Exn.Exn(exn) => add_error(Log_File.plain_name(file), exn)
78866
1bd52b048f8e more parallelism via consumer thread: with mailbox limit to avoid ressource problems;
wenzelm
parents: 78863
diff changeset
  1098
          }
77748
5a2a297a91f8 more robust errors: proceed updating database;
wenzelm
parents: 77747
diff changeset
  1099
        }
65642
1423cbbc542d clarified database update operations;
wenzelm
parents: 65639
diff changeset
  1100
      }
78866
1bd52b048f8e more parallelism via consumer thread: with mailbox limit to avoid ressource problems;
wenzelm
parents: 78863
diff changeset
  1101
      finally { consumer.shutdown() }
77745
ebf70b199db7 clarified signature;
wenzelm
parents: 77744
diff changeset
  1102
78866
1bd52b048f8e more parallelism via consumer thread: with mailbox limit to avoid ressource problems;
wenzelm
parents: 78863
diff changeset
  1103
      errors_result.value
65605
a6447eb6bc38 separate small meta_info vs. big build_info;
wenzelm
parents: 65603
diff changeset
  1104
    }
a6447eb6bc38 separate small meta_info vs. big build_info;
wenzelm
parents: 65603
diff changeset
  1105
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 74782
diff changeset
  1106
    def read_meta_info(db: SQL.Database, log_name: String): Option[Meta_Info] = {
78849
df162316b6a7 clarified names;
wenzelm
parents: 78843
diff changeset
  1107
      val table = private_data.meta_info_table
65642
1423cbbc542d clarified database update operations;
wenzelm
parents: 65639
diff changeset
  1108
      val columns = table.columns.tail
77552
080422b3d914 clarified signature: reduce boilerplate;
wenzelm
parents: 77551
diff changeset
  1109
      db.execute_query_statementO[Meta_Info](
78849
df162316b6a7 clarified names;
wenzelm
parents: 78843
diff changeset
  1110
        table.select(columns, sql = private_data.log_name.where_equal(log_name)),
77552
080422b3d914 clarified signature: reduce boilerplate;
wenzelm
parents: 77551
diff changeset
  1111
        { res =>
65621
551950dccec6 operations to read database;
wenzelm
parents: 65619
diff changeset
  1112
          val results =
65642
1423cbbc542d clarified database update operations;
wenzelm
parents: 65639
diff changeset
  1113
            columns.map(c => c.name ->
65621
551950dccec6 operations to read database;
wenzelm
parents: 65619
diff changeset
  1114
              (if (c.T == SQL.Type.Date)
65740
83388f09e9ab clarified signature;
wenzelm
parents: 65738
diff changeset
  1115
                res.get_date(c).map(Log_File.Date_Format(_))
65621
551950dccec6 operations to read database;
wenzelm
parents: 65619
diff changeset
  1116
               else
65740
83388f09e9ab clarified signature;
wenzelm
parents: 65738
diff changeset
  1117
                res.get_string(c)))
65621
551950dccec6 operations to read database;
wenzelm
parents: 65619
diff changeset
  1118
          val n = Prop.all_props.length
78592
fdfe9b91d96e misc tuning: support "scalac -source 3.3";
wenzelm
parents: 78400
diff changeset
  1119
          val props = for (case (x, Some(y)) <- results.take(n)) yield (x, y)
fdfe9b91d96e misc tuning: support "scalac -source 3.3";
wenzelm
parents: 78400
diff changeset
  1120
          val settings = for (case (x, Some(y)) <- results.drop(n)) yield (x, y)
77544
42c1e5d4ed14 tuned: prefer iterator.nextOption;
wenzelm
parents: 77543
diff changeset
  1121
          Meta_Info(props, settings)
77552
080422b3d914 clarified signature: reduce boilerplate;
wenzelm
parents: 77551
diff changeset
  1122
        }
080422b3d914 clarified signature: reduce boilerplate;
wenzelm
parents: 77551
diff changeset
  1123
      )
65621
551950dccec6 operations to read database;
wenzelm
parents: 65619
diff changeset
  1124
    }
551950dccec6 operations to read database;
wenzelm
parents: 65619
diff changeset
  1125
551950dccec6 operations to read database;
wenzelm
parents: 65619
diff changeset
  1126
    def read_build_info(
65629
e6c0afe672fa optional ml_statistics: much faster;
wenzelm
parents: 65628
diff changeset
  1127
      db: SQL.Database,
e6c0afe672fa optional ml_statistics: much faster;
wenzelm
parents: 65628
diff changeset
  1128
      log_name: String,
e6c0afe672fa optional ml_statistics: much faster;
wenzelm
parents: 65628
diff changeset
  1129
      session_names: List[String] = Nil,
77405
71f1abff8271 tuned whitespace;
wenzelm
parents: 77404
diff changeset
  1130
      ml_statistics: Boolean = false
71f1abff8271 tuned whitespace;
wenzelm
parents: 77404
diff changeset
  1131
    ): Build_Info = {
78849
df162316b6a7 clarified names;
wenzelm
parents: 78843
diff changeset
  1132
      val table1 = private_data.sessions_table
df162316b6a7 clarified names;
wenzelm
parents: 78843
diff changeset
  1133
      val table2 = private_data.ml_statistics_table
65629
e6c0afe672fa optional ml_statistics: much faster;
wenzelm
parents: 65628
diff changeset
  1134
65645
2c704ae04db1 clarified database layout: bulky ml_statistics are stored/retrieved separately;
wenzelm
parents: 65643
diff changeset
  1135
      val columns1 = table1.columns.tail.map(_.apply(table1))
2c704ae04db1 clarified database layout: bulky ml_statistics are stored/retrieved separately;
wenzelm
parents: 65643
diff changeset
  1136
      val (columns, from) =
2c704ae04db1 clarified database layout: bulky ml_statistics are stored/retrieved separately;
wenzelm
parents: 65643
diff changeset
  1137
        if (ml_statistics) {
78849
df162316b6a7 clarified names;
wenzelm
parents: 78843
diff changeset
  1138
          val columns = columns1 ::: List(private_data.ml_statistics(table2))
65668
366bc4e6a238 more operations;
wenzelm
parents: 65665
diff changeset
  1139
          val join =
77402
wenzelm
parents: 77401
diff changeset
  1140
            table1.ident + SQL.join_outer + table2.ident + " ON " +
77376
7ab9bac1ca96 tuned: prefer typed operations;
wenzelm
parents: 77375
diff changeset
  1141
              SQL.and(
78849
df162316b6a7 clarified names;
wenzelm
parents: 78843
diff changeset
  1142
                private_data.log_name(table1).ident + " = " + private_data.log_name(table2).ident,
df162316b6a7 clarified names;
wenzelm
parents: 78843
diff changeset
  1143
                private_data.session_name(table1).ident + " = " + private_data.session_name(table2).ident)
65668
366bc4e6a238 more operations;
wenzelm
parents: 65665
diff changeset
  1144
          (columns, SQL.enclose(join))
65645
2c704ae04db1 clarified database layout: bulky ml_statistics are stored/retrieved separately;
wenzelm
parents: 65643
diff changeset
  1145
        }
65695
4edac706bc5e tuned signature;
wenzelm
parents: 65694
diff changeset
  1146
        else (columns1, table1.ident)
65645
2c704ae04db1 clarified database layout: bulky ml_statistics are stored/retrieved separately;
wenzelm
parents: 65643
diff changeset
  1147
77404
wenzelm
parents: 77403
diff changeset
  1148
      val where =
78153
55a6aa77f3d8 tuned signature: more operations;
wenzelm
parents: 77798
diff changeset
  1149
        SQL.where_and(
78849
df162316b6a7 clarified names;
wenzelm
parents: 78843
diff changeset
  1150
          private_data.log_name(table1).equal(log_name),
df162316b6a7 clarified names;
wenzelm
parents: 78843
diff changeset
  1151
          private_data.session_name(table1).ident + " <> ''",
df162316b6a7 clarified names;
wenzelm
parents: 78843
diff changeset
  1152
          if_proper(session_names, private_data.session_name(table1).member(session_names)))
77404
wenzelm
parents: 77403
diff changeset
  1153
65621
551950dccec6 operations to read database;
wenzelm
parents: 65619
diff changeset
  1154
      val sessions =
77552
080422b3d914 clarified signature: reduce boilerplate;
wenzelm
parents: 77551
diff changeset
  1155
        db.execute_query_statement(
080422b3d914 clarified signature: reduce boilerplate;
wenzelm
parents: 77551
diff changeset
  1156
          SQL.select(columns, sql = from + where),
080422b3d914 clarified signature: reduce boilerplate;
wenzelm
parents: 77551
diff changeset
  1157
          Map.from[String, Session_Entry],
080422b3d914 clarified signature: reduce boilerplate;
wenzelm
parents: 77551
diff changeset
  1158
          { res =>
78849
df162316b6a7 clarified names;
wenzelm
parents: 78843
diff changeset
  1159
            val session_name = res.string(private_data.session_name)
65626
wenzelm
parents: 65625
diff changeset
  1160
            val session_entry =
wenzelm
parents: 65625
diff changeset
  1161
              Session_Entry(
78849
df162316b6a7 clarified names;
wenzelm
parents: 78843
diff changeset
  1162
                chapter = res.string(private_data.chapter),
df162316b6a7 clarified names;
wenzelm
parents: 78843
diff changeset
  1163
                groups = split_lines(res.string(private_data.groups)),
df162316b6a7 clarified names;
wenzelm
parents: 78843
diff changeset
  1164
                hostname = res.get_string(private_data.hostname),
df162316b6a7 clarified names;
wenzelm
parents: 78843
diff changeset
  1165
                threads = res.get_int(private_data.threads),
77494
1a32b4928aad tuned whitespace;
wenzelm
parents: 77405
diff changeset
  1166
                timing =
1a32b4928aad tuned whitespace;
wenzelm
parents: 77405
diff changeset
  1167
                  res.timing(
78849
df162316b6a7 clarified names;
wenzelm
parents: 78843
diff changeset
  1168
                    private_data.timing_elapsed,
df162316b6a7 clarified names;
wenzelm
parents: 78843
diff changeset
  1169
                    private_data.timing_cpu,
df162316b6a7 clarified names;
wenzelm
parents: 78843
diff changeset
  1170
                    private_data.timing_gc),
65626
wenzelm
parents: 65625
diff changeset
  1171
                ml_timing =
77494
1a32b4928aad tuned whitespace;
wenzelm
parents: 77405
diff changeset
  1172
                  res.timing(
78849
df162316b6a7 clarified names;
wenzelm
parents: 78843
diff changeset
  1173
                    private_data.ml_timing_elapsed,
df162316b6a7 clarified names;
wenzelm
parents: 78843
diff changeset
  1174
                    private_data.ml_timing_cpu,
df162316b6a7 clarified names;
wenzelm
parents: 78843
diff changeset
  1175
                    private_data.ml_timing_gc),
df162316b6a7 clarified names;
wenzelm
parents: 78843
diff changeset
  1176
                sources = res.get_string(private_data.sources),
df162316b6a7 clarified names;
wenzelm
parents: 78843
diff changeset
  1177
                heap_size = res.get_long(private_data.heap_size).map(Space.bytes),
df162316b6a7 clarified names;
wenzelm
parents: 78843
diff changeset
  1178
                status = res.get_string(private_data.status).map(Session_Status.valueOf),
df162316b6a7 clarified names;
wenzelm
parents: 78843
diff changeset
  1179
                errors = uncompress_errors(res.bytes(private_data.errors), cache = cache),
65629
e6c0afe672fa optional ml_statistics: much faster;
wenzelm
parents: 65628
diff changeset
  1180
                ml_statistics =
68018
3747fe57eb67 support for XZ.Cache;
wenzelm
parents: 67743
diff changeset
  1181
                  if (ml_statistics) {
78849
df162316b6a7 clarified names;
wenzelm
parents: 78843
diff changeset
  1182
                    Properties.uncompress(res.bytes(private_data.ml_statistics), cache = cache)
68018
3747fe57eb67 support for XZ.Cache;
wenzelm
parents: 67743
diff changeset
  1183
                  }
65629
e6c0afe672fa optional ml_statistics: much faster;
wenzelm
parents: 65628
diff changeset
  1184
                  else Nil)
65626
wenzelm
parents: 65625
diff changeset
  1185
            session_name -> session_entry
77552
080422b3d914 clarified signature: reduce boilerplate;
wenzelm
parents: 77551
diff changeset
  1186
          }
080422b3d914 clarified signature: reduce boilerplate;
wenzelm
parents: 77551
diff changeset
  1187
        )
65621
551950dccec6 operations to read database;
wenzelm
parents: 65619
diff changeset
  1188
      Build_Info(sessions)
551950dccec6 operations to read database;
wenzelm
parents: 65619
diff changeset
  1189
    }
65595
ffd8283b7be0 support for database connection;
wenzelm
parents: 65591
diff changeset
  1190
  }
77744
1398add8c414 clarified modules;
wenzelm
parents: 77679
diff changeset
  1191
1398add8c414 clarified modules;
wenzelm
parents: 77679
diff changeset
  1192
78991
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1193
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1194
  /** build history **/
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1195
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1196
  object History {
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1197
    sealed case class Entry(
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1198
      known: Boolean,
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1199
      isabelle_version: String,
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1200
      afp_version: Option[String],
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1201
      pull_date: Date
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1202
    ) {
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1203
      def unknown: Boolean = !known
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1204
      def versions: (String, Option[String]) = (isabelle_version, afp_version)
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1205
    }
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1206
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1207
    object Run {
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1208
      val empty: Run = Run()
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1209
      def longest(runs: List[Run]): Run = runs.foldLeft(empty)(_ max _)
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1210
    }
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1211
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1212
    sealed case class Run(entries: List[Entry] = Nil) {
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1213
      def is_empty: Boolean = entries.isEmpty
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1214
      val length: Int = entries.length
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1215
      def max(other: Run): Run = if (length >= other.length) this else other
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1216
      def median: Option[Entry] = if (is_empty) None else Some(entries(length / 2))
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1217
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1218
      override def toString: String = {
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1219
        val s = if (is_empty) "" else "length = " + length + ", median = " + median.get.pull_date
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1220
        "Build_Log.History.Run(" + s + ")"
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1221
      }
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1222
    }
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1223
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1224
    def retrieve(
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1225
      db: SQL.Database,
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1226
      days: Int,
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1227
      rev: String,
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1228
      afp_rev: Option[String],
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1229
      sql: PostgreSQL.Source
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1230
    ): History = {
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1231
      val afp = afp_rev.isDefined
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1232
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1233
      val entries =
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1234
        db.execute_query_statement(
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1235
          private_data.select_recent_versions(
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1236
            days = days, rev = rev, afp_rev = afp_rev, sql = SQL.where(sql)),
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1237
          List.from[Entry],
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1238
          { res =>
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1239
            val known = res.bool(private_data.known)
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1240
            val isabelle_version = res.string(Prop.isabelle_version)
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1241
            val afp_version = if (afp) proper_string(res.string(Prop.afp_version)) else None
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1242
            val pull_date = res.date(private_data.pull_date(afp))
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1243
            Entry(known, isabelle_version, afp_version, pull_date)
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1244
          })
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1245
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1246
      new History(entries)
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1247
    }
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1248
  }
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1249
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1250
  final class History private(val entries: List[History.Entry]) {
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1251
    override def toString: String = "Build_Log.History(" + entries.length + ")"
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1252
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1253
    def unknown_runs(
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1254
      pre: History.Entry => Boolean = _ => true,
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1255
      post: History.Run => Boolean = _ => true
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1256
    ): List[History.Run] = {
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1257
      var rest = entries.filter(pre)
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1258
      val result = new mutable.ListBuffer[History.Run]
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1259
      while (rest.nonEmpty) {
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1260
        val (a, b) = Library.take_prefix[History.Entry](_.unknown, rest.dropWhile(_.known))
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1261
        val run = History.Run(a)
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1262
        if (!run.is_empty && post(run)) result += run
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1263
        rest = b
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1264
      }
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1265
      result.toList
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1266
    }
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1267
  }
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1268
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1269
ae2f5fd0bb5d clarified signature and modules: more explicit Build_Log.History;
wenzelm
parents: 78985
diff changeset
  1270
77749
4649c7bfd3f0 provide Isabelle tool wrapper;
wenzelm
parents: 77748
diff changeset
  1271
  /** maintain build_log database **/
77744
1398add8c414 clarified modules;
wenzelm
parents: 77679
diff changeset
  1272
78857
a79bd9d82c00 tuned signature;
wenzelm
parents: 78856
diff changeset
  1273
  def build_log_database(options: Options, logs: List[Path],
77748
5a2a297a91f8 more robust errors: proceed updating database;
wenzelm
parents: 77747
diff changeset
  1274
    progress: Progress = new Progress,
77751
7ac59361791e clarified options;
wenzelm
parents: 77750
diff changeset
  1275
    vacuum: Boolean = false,
77748
5a2a297a91f8 more robust errors: proceed updating database;
wenzelm
parents: 77747
diff changeset
  1276
    ml_statistics: Boolean = false,
77744
1398add8c414 clarified modules;
wenzelm
parents: 77679
diff changeset
  1277
    snapshot: Option[Path] = None
1398add8c414 clarified modules;
wenzelm
parents: 77679
diff changeset
  1278
  ): Unit = {
1398add8c414 clarified modules;
wenzelm
parents: 77679
diff changeset
  1279
    val store = Build_Log.store(options)
77745
ebf70b199db7 clarified signature;
wenzelm
parents: 77744
diff changeset
  1280
78857
a79bd9d82c00 tuned signature;
wenzelm
parents: 78856
diff changeset
  1281
    val log_files = Log_File.find_files(logs.map(_.file))
77745
ebf70b199db7 clarified signature;
wenzelm
parents: 77744
diff changeset
  1282
77744
1398add8c414 clarified modules;
wenzelm
parents: 77679
diff changeset
  1283
    using(store.open_database()) { db =>
77751
7ac59361791e clarified options;
wenzelm
parents: 77750
diff changeset
  1284
      if (vacuum) db.vacuum()
77748
5a2a297a91f8 more robust errors: proceed updating database;
wenzelm
parents: 77747
diff changeset
  1285
5a2a297a91f8 more robust errors: proceed updating database;
wenzelm
parents: 77747
diff changeset
  1286
      progress.echo("Updating database " + db + " ...")
5a2a297a91f8 more robust errors: proceed updating database;
wenzelm
parents: 77747
diff changeset
  1287
      val errors =
78878
d03bbdd9e735 just one pass is sufficient (see also cc8391b92747, 3e8a897042d9);
wenzelm
parents: 78877
diff changeset
  1288
        store.write_info(db, log_files, ml_statistics = ml_statistics, progress = progress)
77748
5a2a297a91f8 more robust errors: proceed updating database;
wenzelm
parents: 77747
diff changeset
  1289
5a2a297a91f8 more robust errors: proceed updating database;
wenzelm
parents: 77747
diff changeset
  1290
      if (errors.isEmpty) {
5a2a297a91f8 more robust errors: proceed updating database;
wenzelm
parents: 77747
diff changeset
  1291
        for (path <- snapshot) {
78894
1fbfe0bca5e1 tuned message;
wenzelm
parents: 78880
diff changeset
  1292
          progress.echo("Writing database snapshot " + path.expand)
77748
5a2a297a91f8 more robust errors: proceed updating database;
wenzelm
parents: 77747
diff changeset
  1293
          store.snapshot_database(db, path)
5a2a297a91f8 more robust errors: proceed updating database;
wenzelm
parents: 77747
diff changeset
  1294
        }
5a2a297a91f8 more robust errors: proceed updating database;
wenzelm
parents: 77747
diff changeset
  1295
      }
5a2a297a91f8 more robust errors: proceed updating database;
wenzelm
parents: 77747
diff changeset
  1296
      else {
5a2a297a91f8 more robust errors: proceed updating database;
wenzelm
parents: 77747
diff changeset
  1297
        error(cat_lines(List.from(
77750
a8c52c99fa92 tuned messages;
wenzelm
parents: 77749
diff changeset
  1298
          for ((name, rev_errs) <- errors.iterator_list) yield {
a8c52c99fa92 tuned messages;
wenzelm
parents: 77749
diff changeset
  1299
            val err = "The error(s) above occurred in " + quote(name)
a8c52c99fa92 tuned messages;
wenzelm
parents: 77749
diff changeset
  1300
            cat_lines((err :: rev_errs).reverse)
a8c52c99fa92 tuned messages;
wenzelm
parents: 77749
diff changeset
  1301
          }
a8c52c99fa92 tuned messages;
wenzelm
parents: 77749
diff changeset
  1302
        )))
77748
5a2a297a91f8 more robust errors: proceed updating database;
wenzelm
parents: 77747
diff changeset
  1303
      }
77744
1398add8c414 clarified modules;
wenzelm
parents: 77679
diff changeset
  1304
    }
1398add8c414 clarified modules;
wenzelm
parents: 77679
diff changeset
  1305
  }
77749
4649c7bfd3f0 provide Isabelle tool wrapper;
wenzelm
parents: 77748
diff changeset
  1306
4649c7bfd3f0 provide Isabelle tool wrapper;
wenzelm
parents: 77748
diff changeset
  1307
4649c7bfd3f0 provide Isabelle tool wrapper;
wenzelm
parents: 77748
diff changeset
  1308
  /* Isabelle tool wrapper */
4649c7bfd3f0 provide Isabelle tool wrapper;
wenzelm
parents: 77748
diff changeset
  1309
4649c7bfd3f0 provide Isabelle tool wrapper;
wenzelm
parents: 77748
diff changeset
  1310
  val isabelle_tool = Isabelle_Tool("build_log_database", "update build_log database from log files",
4649c7bfd3f0 provide Isabelle tool wrapper;
wenzelm
parents: 77748
diff changeset
  1311
    Scala_Project.here,
4649c7bfd3f0 provide Isabelle tool wrapper;
wenzelm
parents: 77748
diff changeset
  1312
    { args =>
4649c7bfd3f0 provide Isabelle tool wrapper;
wenzelm
parents: 77748
diff changeset
  1313
      var ml_statistics: Boolean = false
4649c7bfd3f0 provide Isabelle tool wrapper;
wenzelm
parents: 77748
diff changeset
  1314
      var snapshot: Option[Path] = None
77751
7ac59361791e clarified options;
wenzelm
parents: 77750
diff changeset
  1315
      var vacuum = false
78858
763dd9bdb101 clarified message;
wenzelm
parents: 78857
diff changeset
  1316
      var logs: List[Path] = Nil
77749
4649c7bfd3f0 provide Isabelle tool wrapper;
wenzelm
parents: 77748
diff changeset
  1317
      var options = Options.init()
4649c7bfd3f0 provide Isabelle tool wrapper;
wenzelm
parents: 77748
diff changeset
  1318
      var verbose = false
4649c7bfd3f0 provide Isabelle tool wrapper;
wenzelm
parents: 77748
diff changeset
  1319
4649c7bfd3f0 provide Isabelle tool wrapper;
wenzelm
parents: 77748
diff changeset
  1320
      val getopts = Getopts("""
4649c7bfd3f0 provide Isabelle tool wrapper;
wenzelm
parents: 77748
diff changeset
  1321
Usage: isabelle build_log_database [OPTIONS]
4649c7bfd3f0 provide Isabelle tool wrapper;
wenzelm
parents: 77748
diff changeset
  1322
4649c7bfd3f0 provide Isabelle tool wrapper;
wenzelm
parents: 77748
diff changeset
  1323
  Options are:
4649c7bfd3f0 provide Isabelle tool wrapper;
wenzelm
parents: 77748
diff changeset
  1324
    -M           include ML statistics
4649c7bfd3f0 provide Isabelle tool wrapper;
wenzelm
parents: 77748
diff changeset
  1325
    -S FILE      snapshot to SQLite db file
77751
7ac59361791e clarified options;
wenzelm
parents: 77750
diff changeset
  1326
    -V           vacuum cleaning of database
78858
763dd9bdb101 clarified message;
wenzelm
parents: 78857
diff changeset
  1327
    -d LOG       include log file start location
77749
4649c7bfd3f0 provide Isabelle tool wrapper;
wenzelm
parents: 77748
diff changeset
  1328
    -o OPTION    override Isabelle system OPTION (via NAME=VAL or NAME)
4649c7bfd3f0 provide Isabelle tool wrapper;
wenzelm
parents: 77748
diff changeset
  1329
    -v           verbose
4649c7bfd3f0 provide Isabelle tool wrapper;
wenzelm
parents: 77748
diff changeset
  1330
78858
763dd9bdb101 clarified message;
wenzelm
parents: 78857
diff changeset
  1331
  Update the build_log database server from log files, which are recursively
763dd9bdb101 clarified message;
wenzelm
parents: 78857
diff changeset
  1332
  collected from given start locations (files or directories).
77749
4649c7bfd3f0 provide Isabelle tool wrapper;
wenzelm
parents: 77748
diff changeset
  1333
""",
4649c7bfd3f0 provide Isabelle tool wrapper;
wenzelm
parents: 77748
diff changeset
  1334
        "M" -> (_ => ml_statistics = true),
4649c7bfd3f0 provide Isabelle tool wrapper;
wenzelm
parents: 77748
diff changeset
  1335
        "S:" -> (arg => snapshot = Some(Path.explode(arg))),
77751
7ac59361791e clarified options;
wenzelm
parents: 77750
diff changeset
  1336
        "V" -> (_ => vacuum = true),
78858
763dd9bdb101 clarified message;
wenzelm
parents: 78857
diff changeset
  1337
        "d:" -> (arg => logs = logs ::: List(Path.explode(arg))),
77749
4649c7bfd3f0 provide Isabelle tool wrapper;
wenzelm
parents: 77748
diff changeset
  1338
        "o:" -> (arg => options = options + arg),
4649c7bfd3f0 provide Isabelle tool wrapper;
wenzelm
parents: 77748
diff changeset
  1339
        "v" -> (_ => verbose = true))
4649c7bfd3f0 provide Isabelle tool wrapper;
wenzelm
parents: 77748
diff changeset
  1340
4649c7bfd3f0 provide Isabelle tool wrapper;
wenzelm
parents: 77748
diff changeset
  1341
      val more_args = getopts(args)
4649c7bfd3f0 provide Isabelle tool wrapper;
wenzelm
parents: 77748
diff changeset
  1342
      if (more_args.nonEmpty) getopts.usage()
4649c7bfd3f0 provide Isabelle tool wrapper;
wenzelm
parents: 77748
diff changeset
  1343
4649c7bfd3f0 provide Isabelle tool wrapper;
wenzelm
parents: 77748
diff changeset
  1344
      val progress = new Console_Progress(verbose = verbose)
4649c7bfd3f0 provide Isabelle tool wrapper;
wenzelm
parents: 77748
diff changeset
  1345
78858
763dd9bdb101 clarified message;
wenzelm
parents: 78857
diff changeset
  1346
      build_log_database(options, logs, progress = progress, vacuum = vacuum,
77749
4649c7bfd3f0 provide Isabelle tool wrapper;
wenzelm
parents: 77748
diff changeset
  1347
        ml_statistics = ml_statistics, snapshot = snapshot)
4649c7bfd3f0 provide Isabelle tool wrapper;
wenzelm
parents: 77748
diff changeset
  1348
    })
64045
c6160d0b0337 clarified modules;
wenzelm
parents:
diff changeset
  1349
}