| author | desharna |
| Sat, 04 Jun 2022 18:32:30 +0200 | |
| changeset 75540 | 02719bd7b4e6 |
| parent 75394 | 42267c650205 |
| child 75518 | cb4af8c6152f |
| permissions | -rw-r--r-- |
| 64160 | 1 |
/* Title: Pure/Admin/build_log.scala |
| 64045 | 2 |
Author: Makarius |
3 |
||
| 65608 | 4 |
Management of build log files and database storage. |
| 64045 | 5 |
*/ |
6 |
||
7 |
package isabelle |
|
8 |
||
9 |
||
| 64100 | 10 |
import java.io.{File => JFile}
|
| 64110 | 11 |
import java.time.format.{DateTimeFormatter, DateTimeParseException}
|
| 64096 | 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 | 14 |
import scala.collection.immutable.SortedMap |
| 64054 | 15 |
import scala.collection.mutable |
16 |
import scala.util.matching.Regex |
|
17 |
||
18 |
||
| 75393 | 19 |
object Build_Log {
|
| 64298 | 20 |
/** content **/ |
| 64101 | 21 |
|
| 64298 | 22 |
/* properties */ |
| 64150 | 23 |
|
| 75393 | 24 |
object Prop {
|
| 65624 | 25 |
val build_tags = SQL.Column.string("build_tags") // lines
|
26 |
val build_args = SQL.Column.string("build_args") // lines
|
|
| 65591 | 27 |
val build_group_id = SQL.Column.string("build_group_id")
|
28 |
val build_id = SQL.Column.string("build_id")
|
|
29 |
val build_engine = SQL.Column.string("build_engine")
|
|
30 |
val build_host = SQL.Column.string("build_host")
|
|
31 |
val build_start = SQL.Column.date("build_start")
|
|
32 |
val build_end = SQL.Column.date("build_end")
|
|
33 |
val isabelle_version = SQL.Column.string("isabelle_version")
|
|
34 |
val afp_version = SQL.Column.string("afp_version")
|
|
35 |
||
| 65611 | 36 |
val all_props: List[SQL.Column] = |
| 65591 | 37 |
List(build_tags, build_args, build_group_id, build_id, build_engine, |
38 |
build_host, build_start, build_end, isabelle_version, afp_version) |
|
| 64298 | 39 |
} |
| 64150 | 40 |
|
41 |
||
| 64298 | 42 |
/* settings */ |
| 64080 | 43 |
|
| 75393 | 44 |
object Settings {
|
| 65611 | 45 |
val ISABELLE_BUILD_OPTIONS = SQL.Column.string("ISABELLE_BUILD_OPTIONS")
|
46 |
val ML_PLATFORM = SQL.Column.string("ML_PLATFORM")
|
|
47 |
val ML_HOME = SQL.Column.string("ML_HOME")
|
|
48 |
val ML_SYSTEM = SQL.Column.string("ML_SYSTEM")
|
|
49 |
val ML_OPTIONS = SQL.Column.string("ML_OPTIONS")
|
|
50 |
||
51 |
val ml_settings = List(ML_PLATFORM, ML_HOME, ML_SYSTEM, ML_OPTIONS) |
|
52 |
val all_settings = ISABELLE_BUILD_OPTIONS :: ml_settings |
|
| 64081 | 53 |
|
54 |
type Entry = (String, String) |
|
55 |
type T = List[Entry] |
|
| 64080 | 56 |
|
| 75393 | 57 |
object Entry {
|
| 64081 | 58 |
def unapply(s: String): Option[Entry] = |
| 73712 | 59 |
for { (a, b) <- Properties.Eq.unapply(s) }
|
60 |
yield (a, Library.perhaps_unquote(b)) |
|
| 73713 | 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 | 63 |
} |
| 64080 | 64 |
|
| 71992 | 65 |
def show(): String = |
| 64081 | 66 |
cat_lines( |
| 71992 | 67 |
List(Entry.getenv("ISABELLE_TOOL_JAVA_OPTIONS"),
|
68 |
Entry.getenv(ISABELLE_BUILD_OPTIONS.name), "") ::: |
|
| 65611 | 69 |
ml_settings.map(c => Entry.getenv(c.name))) |
| 64080 | 70 |
} |
71 |
||
72 |
||
| 64298 | 73 |
/* file names */ |
74 |
||
75 |
def log_date(date: Date): String = |
|
76 |
String.format(Locale.ROOT, "%s.%05d", |
|
77 |
DateTimeFormatter.ofPattern("yyyy-MM-dd").format(date.rep),
|
|
| 71163 | 78 |
java.lang.Long.valueOf((date.time - date.midnight.time).ms / 1000)) |
| 64298 | 79 |
|
80 |
def log_subdir(date: Date): Path = |
|
81 |
Path.explode("log") + Path.explode(date.rep.getYear.toString)
|
|
82 |
||
83 |
def log_filename(engine: String, date: Date, more: List[String] = Nil): Path = |
|
84 |
Path.explode((engine :: log_date(date) :: more).mkString("", "_", ".log"))
|
|
85 |
||
86 |
||
| 64100 | 87 |
|
| 64062 | 88 |
/** log file **/ |
| 64045 | 89 |
|
| 64155 | 90 |
def print_date(date: Date): String = Log_File.Date_Format(date) |
91 |
||
| 75393 | 92 |
object Log_File {
|
| 65607 | 93 |
/* log file */ |
94 |
||
| 75393 | 95 |
def plain_name(name: String): String = {
|
| 71621 | 96 |
List(".log", ".log.gz", ".log.xz", ".gz", ".xz").find(name.endsWith) match {
|
| 65609 | 97 |
case Some(s) => Library.try_unsuffix(s, name).get |
98 |
case None => name |
|
99 |
} |
|
100 |
} |
|
101 |
||
| 64062 | 102 |
def apply(name: String, lines: List[String]): Log_File = |
|
71653
6f7a54954f19
more robust: process stdout on Windows may contain CR;
wenzelm
parents:
71630
diff
changeset
|
103 |
new Log_File(plain_name(name), lines.map(Library.trim_line)) |
| 64062 | 104 |
|
105 |
def apply(name: String, text: String): Log_File = |
|
|
71653
6f7a54954f19
more robust: process stdout on Windows may contain CR;
wenzelm
parents:
71630
diff
changeset
|
106 |
new Log_File(plain_name(name), Library.trim_split_lines(text)) |
| 64090 | 107 |
|
| 75393 | 108 |
def apply(file: JFile): Log_File = {
|
| 64090 | 109 |
val name = file.getName |
| 65609 | 110 |
val text = |
111 |
if (name.endsWith(".gz")) File.read_gzip(file)
|
|
112 |
else if (name.endsWith(".xz")) File.read_xz(file)
|
|
113 |
else File.read(file) |
|
114 |
apply(name, text) |
|
| 64090 | 115 |
} |
116 |
||
117 |
def apply(path: Path): Log_File = apply(path.file) |
|
| 64101 | 118 |
|
| 64110 | 119 |
|
| 65607 | 120 |
/* log file collections */ |
121 |
||
122 |
def is_log(file: JFile, |
|
123 |
prefixes: List[String] = |
|
|
66995
9cb263dbb2f7
plain identify job for Isabelle + AFP, independent of any Isabelle technology;
wenzelm
parents:
66944
diff
changeset
|
124 |
List(Build_History.log_prefix, Identify.log_prefix, Identify.log_prefix2, |
|
9cb263dbb2f7
plain identify job for Isabelle + AFP, independent of any Isabelle technology;
wenzelm
parents:
66944
diff
changeset
|
125 |
Isatest.log_prefix, AFP_Test.log_prefix, Jenkins.log_prefix), |
| 75393 | 126 |
suffixes: List[String] = List(".log", ".log.gz", ".log.xz")
|
127 |
): Boolean = {
|
|
| 65607 | 128 |
val name = file.getName |
| 65639 | 129 |
|
| 71621 | 130 |
prefixes.exists(name.startsWith) && |
131 |
suffixes.exists(name.endsWith) && |
|
| 65639 | 132 |
name != "isatest.log" && |
133 |
name != "afp-test.log" && |
|
134 |
name != "main.log" |
|
| 65607 | 135 |
} |
136 |
||
137 |
||
| 64110 | 138 |
/* date format */ |
139 |
||
| 75393 | 140 |
val Date_Format = {
|
| 64101 | 141 |
val fmts = |
142 |
Date.Formatter.variants( |
|
| 64116 | 143 |
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
|
144 |
List(Locale.ENGLISH, Locale.GERMAN)) ::: |
| 64110 | 145 |
List( |
146 |
DateTimeFormatter.RFC_1123_DATE_TIME, |
|
| 69980 | 147 |
Date.Formatter.pattern("EEE MMM d HH:mm:ss yyyy").withZone(Date.timezone_berlin))
|
| 64101 | 148 |
|
|
64104
b70fa05d6746
more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents:
64103
diff
changeset
|
149 |
def tune_timezone(s: String): String = |
|
b70fa05d6746
more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents:
64103
diff
changeset
|
150 |
s match {
|
| 64101 | 151 |
case "CET" | "MET" => "GMT+1" |
152 |
case "CEST" | "MEST" => "GMT+2" |
|
|
64104
b70fa05d6746
more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents:
64103
diff
changeset
|
153 |
case "EST" => "Europe/Berlin" |
|
b70fa05d6746
more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents:
64103
diff
changeset
|
154 |
case _ => s |
|
b70fa05d6746
more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents:
64103
diff
changeset
|
155 |
} |
|
b70fa05d6746
more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents:
64103
diff
changeset
|
156 |
def tune_weekday(s: String): String = |
|
b70fa05d6746
more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents:
64103
diff
changeset
|
157 |
s match {
|
|
b70fa05d6746
more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents:
64103
diff
changeset
|
158 |
case "Die" => "Di" |
|
b70fa05d6746
more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents:
64103
diff
changeset
|
159 |
case "Mit" => "Mi" |
|
b70fa05d6746
more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents:
64103
diff
changeset
|
160 |
case "Don" => "Do" |
|
b70fa05d6746
more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents:
64103
diff
changeset
|
161 |
case "Fre" => "Fr" |
|
b70fa05d6746
more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents:
64103
diff
changeset
|
162 |
case "Sam" => "Sa" |
|
b70fa05d6746
more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents:
64103
diff
changeset
|
163 |
case "Son" => "So" |
|
b70fa05d6746
more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents:
64103
diff
changeset
|
164 |
case _ => s |
|
b70fa05d6746
more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents:
64103
diff
changeset
|
165 |
} |
|
b70fa05d6746
more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents:
64103
diff
changeset
|
166 |
|
|
b70fa05d6746
more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents:
64103
diff
changeset
|
167 |
def tune(s: String): String = |
|
b70fa05d6746
more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents:
64103
diff
changeset
|
168 |
Word.implode( |
|
b70fa05d6746
more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents:
64103
diff
changeset
|
169 |
Word.explode(s) match {
|
| 71621 | 170 |
case a :: "M\uFFFDr" :: bs => tune_weekday(a) :: "Mär" :: bs.map(tune_timezone) |
171 |
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
|
172 |
case Nil => Nil |
|
b70fa05d6746
more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents:
64103
diff
changeset
|
173 |
} |
|
b70fa05d6746
more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents:
64103
diff
changeset
|
174 |
) |
| 64101 | 175 |
|
176 |
Date.Format.make(fmts, tune) |
|
177 |
} |
|
| 64102 | 178 |
} |
179 |
||
| 75393 | 180 |
class Log_File private(val name: String, val lines: List[String]) {
|
| 64102 | 181 |
log_file => |
182 |
||
183 |
override def toString: String = name |
|
184 |
||
185 |
def text: String = cat_lines(lines) |
|
186 |
||
187 |
def err(msg: String): Nothing = |
|
188 |
error("Error in log file " + quote(name) + ": " + msg)
|
|
189 |
||
190 |
||
191 |
/* date format */ |
|
| 64101 | 192 |
|
| 75393 | 193 |
object Strict_Date {
|
| 64101 | 194 |
def unapply(s: String): Some[Date] = |
| 64102 | 195 |
try { Some(Log_File.Date_Format.parse(s)) }
|
| 64101 | 196 |
catch { case exn: DateTimeParseException => log_file.err(exn.getMessage) }
|
197 |
} |
|
198 |
||
199 |
||
| 71620 | 200 |
/* inlined text */ |
| 64062 | 201 |
|
| 71620 | 202 |
def filter(Marker: Protocol_Message.Marker): List[String] = |
203 |
for (Marker(text) <- lines) yield text |
|
| 64062 | 204 |
|
| 71620 | 205 |
def find(Marker: Protocol_Message.Marker): Option[String] = |
206 |
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
|
207 |
|
| 65684 | 208 |
def find_match(regexes: List[Regex]): Option[String] = |
209 |
regexes match {
|
|
210 |
case Nil => None |
|
211 |
case regex :: rest => |
|
212 |
lines.iterator.map(regex.unapplySeq(_)).find(res => res.isDefined && res.get.length == 1). |
|
213 |
map(res => res.get.head) orElse find_match(rest) |
|
214 |
} |
|
| 64062 | 215 |
|
216 |
||
217 |
/* settings */ |
|
218 |
||
|
73715
bf51c23f3f99
clarified signature -- avoid odd warning about scala/bug#6675;
wenzelm
parents:
73713
diff
changeset
|
219 |
def get_setting(name: String): Option[Settings.Entry] = |
|
bf51c23f3f99
clarified signature -- avoid odd warning about scala/bug#6675;
wenzelm
parents:
73713
diff
changeset
|
220 |
lines.collectFirst({ case Settings.Entry(a, b) if a == name => a -> b })
|
| 64045 | 221 |
|
| 65611 | 222 |
def get_all_settings: Settings.T = |
223 |
for { c <- Settings.all_settings; entry <- get_setting(c.name) }
|
|
224 |
yield entry |
|
| 64062 | 225 |
|
226 |
||
227 |
/* properties (YXML) */ |
|
228 |
||
|
73031
f93f0597f4fb
clarified signature: absorb XZ.Cache into XML.Cache;
wenzelm
parents:
73025
diff
changeset
|
229 |
val cache: XML.Cache = XML.Cache.make() |
| 64062 | 230 |
|
231 |
def parse_props(text: String): Properties.T = |
|
|
73031
f93f0597f4fb
clarified signature: absorb XZ.Cache into XML.Cache;
wenzelm
parents:
73025
diff
changeset
|
232 |
try { cache.props(XML.Decode.properties(YXML.parse_body(text))) }
|
| 66046 | 233 |
catch { case _: XML.Error => log_file.err("malformed properties") }
|
| 64062 | 234 |
|
| 71620 | 235 |
def filter_props(marker: Protocol_Message.Marker): List[Properties.T] = |
236 |
for (text <- filter(marker) if YXML.detect(text)) yield parse_props(text) |
|
| 64062 | 237 |
|
| 71620 | 238 |
def find_props(marker: Protocol_Message.Marker): Option[Properties.T] = |
239 |
for (text <- find(marker) if YXML.detect(text)) yield parse_props(text) |
|
| 64062 | 240 |
|
241 |
||
242 |
/* parse various formats */ |
|
243 |
||
| 64105 | 244 |
def parse_meta_info(): Meta_Info = Build_Log.parse_meta_info(log_file) |
245 |
||
| 65646 | 246 |
def parse_build_info(ml_statistics: Boolean = false): Build_Info = |
247 |
Build_Log.parse_build_info(log_file, ml_statistics) |
|
| 64105 | 248 |
|
| 64082 | 249 |
def parse_session_info( |
250 |
command_timings: Boolean = false, |
|
|
66873
9953ae603a23
provide theory timing information, similar to command timing but always considered relevant;
wenzelm
parents:
66863
diff
changeset
|
251 |
theory_timings: Boolean = false, |
| 64082 | 252 |
ml_statistics: Boolean = false, |
253 |
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
|
254 |
Build_Log.parse_session_info( |
|
9953ae603a23
provide theory timing information, similar to command timing but always considered relevant;
wenzelm
parents:
66863
diff
changeset
|
255 |
log_file, command_timings, theory_timings, ml_statistics, task_statistics) |
| 64045 | 256 |
} |
257 |
||
258 |
||
| 64098 | 259 |
|
| 65276 | 260 |
/** digested meta info: produced by Admin/build_history in log.xz file **/ |
| 64045 | 261 |
|
| 75393 | 262 |
object Meta_Info {
|
| 64108 | 263 |
val empty: Meta_Info = Meta_Info(Nil, Nil) |
| 64099 | 264 |
} |
| 64098 | 265 |
|
| 75393 | 266 |
sealed case class Meta_Info(props: Properties.T, settings: Settings.T) {
|
| 64103 | 267 |
def is_empty: Boolean = props.isEmpty && settings.isEmpty |
| 65599 | 268 |
|
| 65611 | 269 |
def get(c: SQL.Column): Option[String] = |
270 |
Properties.get(props, c.name) orElse |
|
271 |
Properties.get(settings, c.name) |
|
272 |
||
273 |
def get_date(c: SQL.Column): Option[Date] = |
|
| 71621 | 274 |
get(c).map(Log_File.Date_Format.parse) |
| 64103 | 275 |
} |
|
64061
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
276 |
|
| 75393 | 277 |
object Identify {
|
| 65625 | 278 |
val log_prefix = "isabelle_identify_" |
|
66995
9cb263dbb2f7
plain identify job for Isabelle + AFP, independent of any Isabelle technology;
wenzelm
parents:
66944
diff
changeset
|
279 |
val log_prefix2 = "plain_identify_" |
|
65674
23897f5d885d
approximate repository identify job based on isabelle-nightly-slow;
wenzelm
parents:
65670
diff
changeset
|
280 |
|
|
23897f5d885d
approximate repository identify job based on isabelle-nightly-slow;
wenzelm
parents:
65670
diff
changeset
|
281 |
def engine(log_file: Log_File): String = |
|
23897f5d885d
approximate repository identify job based on isabelle-nightly-slow;
wenzelm
parents:
65670
diff
changeset
|
282 |
if (log_file.name.startsWith(Jenkins.log_prefix)) "jenkins_identify" |
|
66995
9cb263dbb2f7
plain identify job for Isabelle + AFP, independent of any Isabelle technology;
wenzelm
parents:
66944
diff
changeset
|
283 |
else if (log_file.name.startsWith(log_prefix2)) "plain_identify" |
|
65674
23897f5d885d
approximate repository identify job based on isabelle-nightly-slow;
wenzelm
parents:
65670
diff
changeset
|
284 |
else "identify" |
|
23897f5d885d
approximate repository identify job based on isabelle-nightly-slow;
wenzelm
parents:
65670
diff
changeset
|
285 |
|
|
23897f5d885d
approximate repository identify job based on isabelle-nightly-slow;
wenzelm
parents:
65670
diff
changeset
|
286 |
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
|
287 |
terminate_lines( |
|
23897f5d885d
approximate repository identify job based on isabelle-nightly-slow;
wenzelm
parents:
65670
diff
changeset
|
288 |
List("isabelle_identify: " + Build_Log.print_date(date), "") :::
|
|
23897f5d885d
approximate repository identify job based on isabelle-nightly-slow;
wenzelm
parents:
65670
diff
changeset
|
289 |
isabelle_version.map("Isabelle version: " + _).toList :::
|
|
23897f5d885d
approximate repository identify job based on isabelle-nightly-slow;
wenzelm
parents:
65670
diff
changeset
|
290 |
afp_version.map("AFP version: " + _).toList)
|
|
23897f5d885d
approximate repository identify job based on isabelle-nightly-slow;
wenzelm
parents:
65670
diff
changeset
|
291 |
|
| 65625 | 292 |
val Start = new Regex("""^isabelle_identify: (.+)$""")
|
293 |
val No_End = new Regex("""$.""")
|
|
| 65684 | 294 |
val Isabelle_Version = List(new Regex("""^Isabelle version: (\S+)$"""))
|
295 |
val AFP_Version = List(new Regex("""^AFP version: (\S+)$"""))
|
|
| 65625 | 296 |
} |
297 |
||
| 75393 | 298 |
object Isatest {
|
| 65588 | 299 |
val log_prefix = "isatest-makeall-" |
| 64108 | 300 |
val engine = "isatest" |
| 64109 | 301 |
val Start = new Regex("""^------------------- starting test --- (.+) --- (.+)$""")
|
302 |
val End = new Regex("""^------------------- test (?:successful|FAILED) --- (.+) --- .*$""")
|
|
| 65684 | 303 |
val Isabelle_Version = List(new Regex("""^Isabelle version: (\S+)$"""))
|
| 64095 | 304 |
} |
305 |
||
| 75393 | 306 |
object AFP_Test {
|
| 65588 | 307 |
val log_prefix = "afp-test-devel-" |
| 64108 | 308 |
val engine = "afp-test" |
| 64109 | 309 |
val Start = new Regex("""^Start test(?: for .+)? at ([^,]+), (.*)$""")
|
310 |
val Start_Old = new Regex("""^Start test(?: for .+)? at ([^,]+)$""")
|
|
311 |
val End = new Regex("""^End test on (.+), .+, elapsed time:.*$""")
|
|
| 65684 | 312 |
val Isabelle_Version = List(new Regex("""^Isabelle version: .* -- hg id (\S+)$"""))
|
313 |
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
|
314 |
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
|
315 |
} |
|
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
316 |
|
| 75393 | 317 |
object Jenkins {
|
| 65664 | 318 |
val log_prefix = "jenkins_" |
| 64110 | 319 |
val engine = "jenkins" |
| 65663 | 320 |
val Host = new Regex("""^Building remotely on (\S+) \((\S+)\).*$""")
|
| 65665 | 321 |
val Start = new Regex("""^(?:Started by an SCM change|Started from command line by admin|).*$""")
|
| 64110 | 322 |
val Start_Date = new Regex("""^Build started at (.+)$""")
|
323 |
val No_End = new Regex("""$.""")
|
|
|
65674
23897f5d885d
approximate repository identify job based on isabelle-nightly-slow;
wenzelm
parents:
65670
diff
changeset
|
324 |
val Isabelle_Version = |
| 65684 | 325 |
List(new Regex("""^(?:Build for Isabelle id|Isabelle id) (\w+).*$"""),
|
| 65685 | 326 |
new Regex("""^ISABELLE_CI_REPO_ID="(\w+)".*$"""),
|
327 |
new Regex("""^(\w{12}) tip.*$"""))
|
|
|
65674
23897f5d885d
approximate repository identify job based on isabelle-nightly-slow;
wenzelm
parents:
65670
diff
changeset
|
328 |
val AFP_Version = |
| 65684 | 329 |
List(new Regex("""^(?:Build for AFP id|AFP id) (\w+).*$"""),
|
330 |
new Regex("""^ISABELLE_CI_AFP_ID="(\w+)".*$"""))
|
|
| 64110 | 331 |
val CONFIGURATION = "=== CONFIGURATION ===" |
332 |
val BUILD = "=== BUILD ===" |
|
333 |
} |
|
334 |
||
| 75393 | 335 |
private def parse_meta_info(log_file: Log_File): Meta_Info = {
|
| 64108 | 336 |
def parse(engine: String, host: String, start: Date, |
| 75393 | 337 |
End: Regex, Isabelle_Version: List[Regex], AFP_Version: List[Regex] |
338 |
): Meta_Info = {
|
|
339 |
val build_id = {
|
|
| 65714 | 340 |
val prefix = proper_string(host) orElse proper_string(engine) getOrElse "build" |
341 |
prefix + ":" + start.time.ms |
|
|
64296
544481988e65
explicit identification of builds and correlated build groups;
wenzelm
parents:
64196
diff
changeset
|
342 |
} |
| 65591 | 343 |
val build_engine = if (engine == "") Nil else List(Prop.build_engine.name -> engine) |
344 |
val build_host = if (host == "") Nil else List(Prop.build_host.name -> host) |
|
| 64108 | 345 |
|
| 65599 | 346 |
val start_date = List(Prop.build_start.name -> print_date(start)) |
| 64091 | 347 |
val end_date = |
348 |
log_file.lines.last match {
|
|
| 64109 | 349 |
case End(log_file.Strict_Date(end_date)) => |
| 65599 | 350 |
List(Prop.build_end.name -> print_date(end_date)) |
| 64091 | 351 |
case _ => Nil |
352 |
} |
|
353 |
||
354 |
val isabelle_version = |
|
| 65591 | 355 |
log_file.find_match(Isabelle_Version).map(Prop.isabelle_version.name -> _) |
| 64091 | 356 |
val afp_version = |
| 65591 | 357 |
log_file.find_match(AFP_Version).map(Prop.afp_version.name -> _) |
| 64062 | 358 |
|
| 65591 | 359 |
Meta_Info((Prop.build_id.name -> build_id) :: build_engine ::: build_host ::: |
| 64108 | 360 |
start_date ::: end_date ::: isabelle_version.toList ::: afp_version.toList, |
| 65611 | 361 |
log_file.get_all_settings) |
| 64091 | 362 |
} |
363 |
||
364 |
log_file.lines match {
|
|
|
71630
50425e4c3910
clarified modules: global quasi-scope for markers;
wenzelm
parents:
71621
diff
changeset
|
365 |
case line :: _ if Protocol.Meta_Info_Marker.test_yxml(line) => |
|
50425e4c3910
clarified modules: global quasi-scope for markers;
wenzelm
parents:
71621
diff
changeset
|
366 |
Meta_Info(log_file.find_props(Protocol.Meta_Info_Marker).get, log_file.get_all_settings) |
| 64117 | 367 |
|
| 65625 | 368 |
case Identify.Start(log_file.Strict_Date(start)) :: _ => |
|
65674
23897f5d885d
approximate repository identify job based on isabelle-nightly-slow;
wenzelm
parents:
65670
diff
changeset
|
369 |
parse(Identify.engine(log_file), "", start, Identify.No_End, |
| 65625 | 370 |
Identify.Isabelle_Version, Identify.AFP_Version) |
371 |
||
| 64109 | 372 |
case Isatest.Start(log_file.Strict_Date(start), host) :: _ => |
373 |
parse(Isatest.engine, host, start, Isatest.End, |
|
| 65684 | 374 |
Isatest.Isabelle_Version, Nil) |
| 64099 | 375 |
|
| 64109 | 376 |
case AFP_Test.Start(log_file.Strict_Date(start), host) :: _ => |
377 |
parse(AFP_Test.engine, host, start, AFP_Test.End, |
|
378 |
AFP_Test.Isabelle_Version, AFP_Test.AFP_Version) |
|
| 64099 | 379 |
|
| 64109 | 380 |
case AFP_Test.Start_Old(log_file.Strict_Date(start)) :: _ => |
381 |
parse(AFP_Test.engine, "", start, AFP_Test.End, |
|
382 |
AFP_Test.Isabelle_Version, AFP_Test.AFP_Version) |
|
| 64099 | 383 |
|
| 65665 | 384 |
case Jenkins.Start() :: _ => |
| 64110 | 385 |
log_file.lines.dropWhile(_ != Jenkins.BUILD) match {
|
386 |
case Jenkins.BUILD :: _ :: Jenkins.Start_Date(log_file.Strict_Date(start)) :: _ => |
|
| 65663 | 387 |
val host = |
388 |
log_file.lines.takeWhile(_ != Jenkins.CONFIGURATION).collectFirst({
|
|
389 |
case Jenkins.Host(a, b) => a + "." + b |
|
390 |
}).getOrElse("")
|
|
| 69980 | 391 |
parse(Jenkins.engine, host, start.to(Date.timezone_berlin), Jenkins.No_End, |
| 64110 | 392 |
Jenkins.Isabelle_Version, Jenkins.AFP_Version) |
393 |
case _ => Meta_Info.empty |
|
394 |
} |
|
395 |
||
| 64341 | 396 |
case line :: _ if line.startsWith("\u0000") => Meta_Info.empty
|
| 64109 | 397 |
case List(Isatest.End(_)) => Meta_Info.empty |
398 |
case _ :: AFP_Test.Bad_Init() :: _ => Meta_Info.empty |
|
| 64105 | 399 |
case Nil => Meta_Info.empty |
|
64104
b70fa05d6746
more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents:
64103
diff
changeset
|
400 |
|
| 64110 | 401 |
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
|
402 |
} |
|
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
403 |
} |
|
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
404 |
|
|
64085
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
405 |
|
| 64098 | 406 |
|
| 65276 | 407 |
/** build info: toplevel output of isabelle build or Admin/build_history **/ |
|
64119
8094eaa38d4b
inline session ML statistics into main build log;
wenzelm
parents:
64117
diff
changeset
|
408 |
|
|
8094eaa38d4b
inline session ML statistics into main build log;
wenzelm
parents:
64117
diff
changeset
|
409 |
val SESSION_NAME = "session_name" |
|
64085
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
410 |
|
| 75393 | 411 |
object Session_Status extends Enumeration {
|
| 65633 | 412 |
val existing, finished, failed, cancelled = Value |
|
64061
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
413 |
} |
|
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
414 |
|
|
64085
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
415 |
sealed case class Session_Entry( |
| 65643 | 416 |
chapter: String = "", |
417 |
groups: List[String] = Nil, |
|
418 |
threads: Option[Int] = None, |
|
419 |
timing: Timing = Timing.zero, |
|
420 |
ml_timing: Timing = Timing.zero, |
|
| 66913 | 421 |
sources: Option[String] = None, |
| 65643 | 422 |
heap_size: Option[Long] = None, |
423 |
status: Option[Session_Status.Value] = None, |
|
| 65937 | 424 |
errors: List[String] = Nil, |
|
66874
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
425 |
theory_timings: Map[String, Timing] = Map.empty, |
| 75393 | 426 |
ml_statistics: List[Properties.T] = Nil |
427 |
) {
|
|
| 65631 | 428 |
def proper_groups: Option[String] = if (groups.isEmpty) None else Some(cat_lines(groups)) |
| 65643 | 429 |
def finished: Boolean = status == Some(Session_Status.finished) |
| 65937 | 430 |
def failed: Boolean = status == Some(Session_Status.failed) |
|
64085
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
431 |
} |
| 64054 | 432 |
|
| 75393 | 433 |
object Build_Info {
|
|
66874
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
434 |
val sessions_dummy: Map[String, Session_Entry] = |
|
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
435 |
Map("" -> Session_Entry(theory_timings = Map("" -> Timing.zero)))
|
|
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
436 |
} |
|
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
437 |
|
| 75393 | 438 |
sealed case class Build_Info(sessions: Map[String, Session_Entry]) {
|
| 65937 | 439 |
def finished_sessions: List[String] = for ((a, b) <- sessions.toList if b.finished) yield a |
440 |
def failed_sessions: List[String] = for ((a, b) <- sessions.toList if b.failed) yield a |
|
| 64054 | 441 |
} |
442 |
||
| 75393 | 443 |
private def parse_build_info(log_file: Log_File, parse_ml_statistics: Boolean): Build_Info = {
|
444 |
object Chapter_Name {
|
|
|
64085
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
445 |
def unapply(s: String): Some[(String, String)] = |
|
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
446 |
space_explode('/', s) match {
|
|
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
447 |
case List(chapter, name) => Some((chapter, name)) |
|
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
448 |
case _ => Some(("", s))
|
|
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
449 |
} |
|
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
450 |
} |
| 64054 | 451 |
|
|
64085
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
452 |
val Session_No_Groups = new Regex("""^Session (\S+)$""")
|
|
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
453 |
val Session_Groups = new Regex("""^Session (\S+) \((.*)\)$""")
|
|
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
454 |
val Session_Finished1 = |
|
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
455 |
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
|
456 |
val Session_Finished2 = |
| 72695 | 457 |
new Regex("""^Finished ([^\s/]+) \((\d+):(\d+):(\d+) elapsed time.*$""")
|
|
64085
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
458 |
val Session_Timing = |
| 65679 | 459 |
new Regex("""^Timing (\S+) \((\d+) threads, (\d+\.\d+)s elapsed time, (\d+\.\d+)s cpu time, (\d+\.\d+)s GC time.*$""")
|
|
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
|
460 |
val Session_Started = new Regex("""^(?:Running|Building) (\S+) \.\.\.$""")
|
| 66913 | 461 |
val Sources = new Regex("""^Sources (\S+) (\S{""" + SHA1.digest_length + """})$""")
|
| 64120 | 462 |
val Heap = new Regex("""^Heap (\S+) \((\d+) bytes\)$""")
|
|
64085
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
463 |
|
| 75393 | 464 |
object Theory_Timing {
|
|
66874
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
465 |
def unapply(line: String): Option[(String, (String, Timing))] = |
|
71630
50425e4c3910
clarified modules: global quasi-scope for markers;
wenzelm
parents:
71621
diff
changeset
|
466 |
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
|
467 |
match {
|
| 72753 | 468 |
case Some((SESSION_NAME, session) :: props) => |
469 |
for (theory <- Markup.Name.unapply(props)) |
|
| 74782 | 470 |
yield (session, theory -> Markup.Timing_Properties.get(props)) |
|
66874
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
471 |
case _ => None |
|
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
472 |
} |
|
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
473 |
} |
|
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
474 |
|
|
64085
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
475 |
var chapter = Map.empty[String, String] |
|
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
476 |
var groups = Map.empty[String, List[String]] |
|
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
477 |
var threads = Map.empty[String, Int] |
| 64054 | 478 |
var timing = Map.empty[String, Timing] |
|
64085
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
479 |
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
|
480 |
var started = Set.empty[String] |
| 66913 | 481 |
var sources = Map.empty[String, String] |
| 65627 | 482 |
var heap_sizes = Map.empty[String, Long] |
|
66874
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
483 |
var theory_timings = Map.empty[String, Map[String, Timing]] |
|
64119
8094eaa38d4b
inline session ML statistics into main build log;
wenzelm
parents:
64117
diff
changeset
|
484 |
var ml_statistics = Map.empty[String, List[Properties.T]] |
| 65937 | 485 |
var errors = Map.empty[String, List[String]] |
|
64119
8094eaa38d4b
inline session ML statistics into main build log;
wenzelm
parents:
64117
diff
changeset
|
486 |
|
|
64085
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
487 |
def all_sessions: Set[String] = |
| 64120 | 488 |
chapter.keySet ++ groups.keySet ++ threads.keySet ++ timing.keySet ++ ml_timing.keySet ++ |
| 72694 | 489 |
started ++ sources.keySet ++ heap_sizes.keySet ++ |
| 66913 | 490 |
theory_timings.keySet ++ ml_statistics.keySet |
|
64085
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
491 |
|
| 64054 | 492 |
|
| 64062 | 493 |
for (line <- log_file.lines) {
|
| 64054 | 494 |
line match {
|
|
64085
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
495 |
case Session_No_Groups(Chapter_Name(chapt, name)) => |
|
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
496 |
chapter += (name -> chapt) |
|
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
497 |
groups += (name -> Nil) |
|
64119
8094eaa38d4b
inline session ML statistics into main build log;
wenzelm
parents:
64117
diff
changeset
|
498 |
|
|
64085
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
499 |
case Session_Groups(Chapter_Name(chapt, name), grps) => |
|
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
500 |
chapter += (name -> chapt) |
|
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
501 |
groups += (name -> Word.explode(grps)) |
|
64119
8094eaa38d4b
inline session ML statistics into main build log;
wenzelm
parents:
64117
diff
changeset
|
502 |
|
|
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
|
503 |
case Session_Started(name) => |
|
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
|
504 |
started += name |
|
64119
8094eaa38d4b
inline session ML statistics into main build log;
wenzelm
parents:
64117
diff
changeset
|
505 |
|
| 64054 | 506 |
case Session_Finished1(name, |
507 |
Value.Int(e1), Value.Int(e2), Value.Int(e3), |
|
508 |
Value.Int(c1), Value.Int(c2), Value.Int(c3)) => |
|
509 |
val elapsed = Time.hms(e1, e2, e3) |
|
510 |
val cpu = Time.hms(c1, c2, c3) |
|
|
64085
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
511 |
timing += (name -> Timing(elapsed, cpu, Time.zero)) |
|
64119
8094eaa38d4b
inline session ML statistics into main build log;
wenzelm
parents:
64117
diff
changeset
|
512 |
|
| 64054 | 513 |
case Session_Finished2(name, |
514 |
Value.Int(e1), Value.Int(e2), Value.Int(e3)) => |
|
515 |
val elapsed = Time.hms(e1, e2, e3) |
|
|
64085
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
516 |
timing += (name -> Timing(elapsed, Time.zero, Time.zero)) |
|
64119
8094eaa38d4b
inline session ML statistics into main build log;
wenzelm
parents:
64117
diff
changeset
|
517 |
|
| 64054 | 518 |
case Session_Timing(name, |
519 |
Value.Int(t), Value.Double(e), Value.Double(c), Value.Double(g)) => |
|
520 |
val elapsed = Time.seconds(e) |
|
521 |
val cpu = Time.seconds(c) |
|
522 |
val gc = Time.seconds(g) |
|
|
64085
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
523 |
ml_timing += (name -> Timing(elapsed, cpu, gc)) |
| 64054 | 524 |
threads += (name -> t) |
|
64119
8094eaa38d4b
inline session ML statistics into main build log;
wenzelm
parents:
64117
diff
changeset
|
525 |
|
| 66913 | 526 |
case Sources(name, s) => |
527 |
sources += (name -> s) |
|
528 |
||
| 64120 | 529 |
case Heap(name, Value.Long(size)) => |
530 |
heap_sizes += (name -> size) |
|
531 |
||
|
71630
50425e4c3910
clarified modules: global quasi-scope for markers;
wenzelm
parents:
71621
diff
changeset
|
532 |
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
|
533 |
line match {
|
|
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
534 |
case Theory_Timing(name, theory_timing) => |
|
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
535 |
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
|
536 |
case _ => log_file.err("malformed theory_timing " + quote(line))
|
|
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
537 |
} |
|
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
538 |
|
|
71630
50425e4c3910
clarified modules: global quasi-scope for markers;
wenzelm
parents:
71621
diff
changeset
|
539 |
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
|
540 |
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
|
541 |
case Some((SESSION_NAME, name) :: props) => |
|
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
542 |
ml_statistics += (name -> (props :: ml_statistics.getOrElse(name, Nil))) |
|
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
543 |
case _ => log_file.err("malformed ML_statistics " + quote(line))
|
|
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
544 |
} |
|
64119
8094eaa38d4b
inline session ML statistics into main build log;
wenzelm
parents:
64117
diff
changeset
|
545 |
|
|
71630
50425e4c3910
clarified modules: global quasi-scope for markers;
wenzelm
parents:
71621
diff
changeset
|
546 |
case _ if Protocol.Error_Message_Marker.test_yxml(line) => |
|
50425e4c3910
clarified modules: global quasi-scope for markers;
wenzelm
parents:
71621
diff
changeset
|
547 |
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
|
548 |
case Some(List((SESSION_NAME, name), (Markup.CONTENT, msg))) => |
| 71620 | 549 |
errors += (name -> (msg :: errors.getOrElse(name, Nil))) |
|
66874
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
550 |
case _ => log_file.err("malformed error message " + quote(line))
|
|
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
551 |
} |
| 65937 | 552 |
|
| 64054 | 553 |
case _ => |
554 |
} |
|
555 |
} |
|
556 |
||
|
64085
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
557 |
val sessions = |
|
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
558 |
Map( |
|
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
559 |
(for (name <- all_sessions.toList) yield {
|
|
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
560 |
val status = |
| 72694 | 561 |
if (timing.isDefinedAt(name) || ml_timing.isDefinedAt(name)) |
| 65633 | 562 |
Session_Status.finished |
563 |
else if (started(name)) Session_Status.failed |
|
564 |
else Session_Status.existing |
|
|
64085
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
565 |
val entry = |
|
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
566 |
Session_Entry( |
| 65643 | 567 |
chapter = chapter.getOrElse(name, ""), |
568 |
groups = groups.getOrElse(name, Nil), |
|
569 |
threads = threads.get(name), |
|
570 |
timing = timing.getOrElse(name, Timing.zero), |
|
571 |
ml_timing = ml_timing.getOrElse(name, Timing.zero), |
|
| 66913 | 572 |
sources = sources.get(name), |
| 65643 | 573 |
heap_size = heap_sizes.get(name), |
574 |
status = Some(status), |
|
| 65937 | 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 | 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 | 581 |
} |
| 64099 | 582 |
|
583 |
||
584 |
||
| 72860 | 585 |
/** session info: produced by isabelle build as session database **/ |
| 64099 | 586 |
|
587 |
sealed case class Session_Info( |
|
588 |
session_timing: Properties.T, |
|
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 | 591 |
ml_statistics: List[Properties.T], |
| 65934 | 592 |
task_statistics: List[Properties.T], |
| 75393 | 593 |
errors: List[String] |
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 | 598 |
|
599 |
private def parse_session_info( |
|
600 |
log_file: Log_File, |
|
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 | 603 |
ml_statistics: Boolean, |
| 75393 | 604 |
task_statistics: Boolean |
605 |
): Session_Info = {
|
|
| 65290 | 606 |
Session_Info( |
| 72012 | 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 | 617 |
} |
| 65595 | 618 |
|
| 73024 | 619 |
def compress_errors(errors: List[String], cache: XZ.Cache = XZ.Cache()): Option[Bytes] = |
| 65937 | 620 |
if (errors.isEmpty) None |
| 68018 | 621 |
else {
|
622 |
Some(Bytes(YXML.string_of_body(XML.Encode.list(XML.Encode.string)(errors))). |
|
623 |
compress(cache = cache)) |
|
624 |
} |
|
| 65937 | 625 |
|
| 73033 | 626 |
def uncompress_errors(bytes: Bytes, cache: XML.Cache = XML.Cache.make()): List[String] = |
| 72885 | 627 |
if (bytes.is_empty) Nil |
| 68018 | 628 |
else {
|
| 73033 | 629 |
XML.Decode.list(YXML.string_of_body)( |
630 |
YXML.parse_body(bytes.uncompress(cache = cache.xz).text, cache = cache)) |
|
| 68018 | 631 |
} |
| 65937 | 632 |
|
| 65595 | 633 |
|
634 |
||
635 |
/** persistent store **/ |
|
636 |
||
| 65694 | 637 |
/* SQL data model */ |
638 |
||
| 75393 | 639 |
object Data {
|
| 65702 | 640 |
def build_log_table(name: String, columns: List[SQL.Column], body: String = ""): SQL.Table = |
| 65700 | 641 |
SQL.Table("isabelle_build_log_" + name, columns, body)
|
642 |
||
643 |
||
| 65694 | 644 |
/* main content */ |
645 |
||
| 66857 | 646 |
val log_name = SQL.Column.string("log_name").make_primary_key
|
647 |
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
|
648 |
val theory_name = SQL.Column.string("theory_name").make_primary_key
|
| 65694 | 649 |
val chapter = SQL.Column.string("chapter")
|
650 |
val groups = SQL.Column.string("groups")
|
|
651 |
val threads = SQL.Column.int("threads")
|
|
652 |
val timing_elapsed = SQL.Column.long("timing_elapsed")
|
|
653 |
val timing_cpu = SQL.Column.long("timing_cpu")
|
|
654 |
val timing_gc = SQL.Column.long("timing_gc")
|
|
655 |
val timing_factor = SQL.Column.double("timing_factor")
|
|
656 |
val ml_timing_elapsed = SQL.Column.long("ml_timing_elapsed")
|
|
657 |
val ml_timing_cpu = SQL.Column.long("ml_timing_cpu")
|
|
658 |
val ml_timing_gc = SQL.Column.long("ml_timing_gc")
|
|
659 |
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
|
660 |
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
|
661 |
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
|
662 |
val theory_timing_gc = SQL.Column.long("theory_timing_gc")
|
| 65694 | 663 |
val heap_size = SQL.Column.long("heap_size")
|
664 |
val status = SQL.Column.string("status")
|
|
| 65937 | 665 |
val errors = SQL.Column.bytes("errors")
|
| 66913 | 666 |
val sources = SQL.Column.string("sources")
|
| 65694 | 667 |
val ml_statistics = SQL.Column.bytes("ml_statistics")
|
|
65783
d3d5cb2d6866
pick isabelle_version based on build_log database;
wenzelm
parents:
65781
diff
changeset
|
668 |
val known = SQL.Column.bool("known")
|
| 65694 | 669 |
|
670 |
val meta_info_table = |
|
| 65702 | 671 |
build_log_table("meta_info", log_name :: Prop.all_props ::: Settings.all_settings)
|
| 65694 | 672 |
|
673 |
val sessions_table = |
|
| 65702 | 674 |
build_log_table("sessions",
|
| 65694 | 675 |
List(log_name, session_name, chapter, groups, threads, timing_elapsed, timing_cpu, |
676 |
timing_gc, timing_factor, ml_timing_elapsed, ml_timing_cpu, ml_timing_gc, ml_timing_factor, |
|
| 66913 | 677 |
heap_size, status, errors, sources)) |
| 65694 | 678 |
|
|
66874
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
679 |
val theories_table = |
|
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
680 |
build_log_table("theories",
|
|
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
681 |
List(log_name, session_name, theory_name, theory_timing_elapsed, theory_timing_cpu, |
|
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
682 |
theory_timing_gc)) |
|
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
683 |
|
| 65694 | 684 |
val ml_statistics_table = |
| 65702 | 685 |
build_log_table("ml_statistics", List(log_name, session_name, ml_statistics))
|
| 65694 | 686 |
|
687 |
||
| 66855 | 688 |
/* AFP versions */ |
689 |
||
| 75393 | 690 |
val isabelle_afp_versions_table: SQL.Table = {
|
| 66855 | 691 |
val version1 = Prop.isabelle_version |
692 |
val version2 = Prop.afp_version |
|
| 66857 | 693 |
build_log_table("isabelle_afp_versions", List(version1.make_primary_key, version2),
|
| 66855 | 694 |
SQL.select(List(version1, version2), distinct = true) + meta_info_table + |
| 66856 | 695 |
" WHERE " + version1.defined + " AND " + version2.defined) |
| 66855 | 696 |
} |
697 |
||
698 |
||
| 65705 | 699 |
/* earliest pull date for repository version (PostgreSQL queries) */ |
| 65694 | 700 |
|
| 71621 | 701 |
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
|
702 |
if (afp) SQL.Column.date("afp_pull_date")
|
|
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66874
diff
changeset
|
703 |
else SQL.Column.date("pull_date")
|
| 65694 | 704 |
|
| 75393 | 705 |
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
|
706 |
val (name, versions) = |
|
6acd1a2bd146
clarified afp_pull_date: both repository versions are relevant;
wenzelm
parents:
66858
diff
changeset
|
707 |
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
|
708 |
else ("pull_date", List(Prop.isabelle_version))
|
| 65694 | 709 |
|
|
66880
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66874
diff
changeset
|
710 |
build_log_table(name, versions.map(_.make_primary_key) ::: List(pull_date(afp)), |
|
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66874
diff
changeset
|
711 |
"SELECT " + versions.mkString(", ") +
|
|
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66874
diff
changeset
|
712 |
", min(" + Prop.build_start + ") AS " + pull_date(afp) +
|
|
66863
6acd1a2bd146
clarified afp_pull_date: both repository versions are relevant;
wenzelm
parents:
66858
diff
changeset
|
713 |
" FROM " + meta_info_table + |
|
6acd1a2bd146
clarified afp_pull_date: both repository versions are relevant;
wenzelm
parents:
66858
diff
changeset
|
714 |
" WHERE " + (versions ::: List(Prop.build_start)).map(_.defined).mkString(" AND ") +
|
|
6acd1a2bd146
clarified afp_pull_date: both repository versions are relevant;
wenzelm
parents:
66858
diff
changeset
|
715 |
" GROUP BY " + versions.mkString(", "))
|
| 66855 | 716 |
} |
717 |
||
718 |
||
719 |
/* recent entries */ |
|
720 |
||
| 65736 | 721 |
def recent_time(days: Int): SQL.Source = |
722 |
"now() - INTERVAL '" + days.max(0) + " days'" |
|
723 |
||
|
66863
6acd1a2bd146
clarified afp_pull_date: both repository versions are relevant;
wenzelm
parents:
66858
diff
changeset
|
724 |
def recent_pull_date_table( |
| 75393 | 725 |
days: Int, |
726 |
rev: String = "", |
|
727 |
afp_rev: Option[String] = None |
|
728 |
): SQL.Table = {
|
|
|
66863
6acd1a2bd146
clarified afp_pull_date: both repository versions are relevant;
wenzelm
parents:
66858
diff
changeset
|
729 |
val afp = afp_rev.isDefined |
|
6acd1a2bd146
clarified afp_pull_date: both repository versions are relevant;
wenzelm
parents:
66858
diff
changeset
|
730 |
val rev2 = afp_rev.getOrElse("")
|
|
6acd1a2bd146
clarified afp_pull_date: both repository versions are relevant;
wenzelm
parents:
66858
diff
changeset
|
731 |
val table = pull_date_table(afp) |
|
6acd1a2bd146
clarified afp_pull_date: both repository versions are relevant;
wenzelm
parents:
66858
diff
changeset
|
732 |
|
|
6acd1a2bd146
clarified afp_pull_date: both repository versions are relevant;
wenzelm
parents:
66858
diff
changeset
|
733 |
val version1 = Prop.isabelle_version |
|
6acd1a2bd146
clarified afp_pull_date: both repository versions are relevant;
wenzelm
parents:
66858
diff
changeset
|
734 |
val version2 = Prop.afp_version |
| 73342 | 735 |
val eq1 = version1(table).toString + " = " + SQL.string(rev) |
736 |
val eq2 = version2(table).toString + " = " + SQL.string(rev2) |
|
|
66863
6acd1a2bd146
clarified afp_pull_date: both repository versions are relevant;
wenzelm
parents:
66858
diff
changeset
|
737 |
|
| 65777 | 738 |
SQL.Table("recent_pull_date", table.columns,
|
|
65783
d3d5cb2d6866
pick isabelle_version based on build_log database;
wenzelm
parents:
65781
diff
changeset
|
739 |
table.select(table.columns, |
|
66880
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66874
diff
changeset
|
740 |
"WHERE " + pull_date(afp)(table) + " > " + recent_time(days) + |
|
66863
6acd1a2bd146
clarified afp_pull_date: both repository versions are relevant;
wenzelm
parents:
66858
diff
changeset
|
741 |
(if (rev != "" && rev2 == "") " OR " + eq1 |
|
6acd1a2bd146
clarified afp_pull_date: both repository versions are relevant;
wenzelm
parents:
66858
diff
changeset
|
742 |
else if (rev == "" && rev2 != "") " OR " + eq2 |
|
6acd1a2bd146
clarified afp_pull_date: both repository versions are relevant;
wenzelm
parents:
66858
diff
changeset
|
743 |
else if (rev != "" && rev2 != "") " OR (" + eq1 + " AND " + eq2 + ")"
|
|
6acd1a2bd146
clarified afp_pull_date: both repository versions are relevant;
wenzelm
parents:
66858
diff
changeset
|
744 |
else ""))) |
| 65702 | 745 |
} |
| 65694 | 746 |
|
| 75393 | 747 |
def select_recent_log_names(days: Int): SQL.Source = {
|
| 65781 | 748 |
val table1 = meta_info_table |
749 |
val table2 = recent_pull_date_table(days) |
|
750 |
table1.select(List(log_name), distinct = true) + SQL.join_inner + table2.query_named + |
|
751 |
" ON " + Prop.isabelle_version(table1) + " = " + Prop.isabelle_version(table2) |
|
752 |
} |
|
753 |
||
| 75393 | 754 |
def select_recent_versions( |
755 |
days: Int, |
|
756 |
rev: String = "", |
|
757 |
afp_rev: Option[String] = None, |
|
758 |
sql: SQL.Source = "" |
|
759 |
): SQL.Source = {
|
|
|
66880
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66874
diff
changeset
|
760 |
val afp = afp_rev.isDefined |
| 66858 | 761 |
val version = Prop.isabelle_version |
|
66863
6acd1a2bd146
clarified afp_pull_date: both repository versions are relevant;
wenzelm
parents:
66858
diff
changeset
|
762 |
val table1 = recent_pull_date_table(days, rev = rev, afp_rev = afp_rev) |
|
65783
d3d5cb2d6866
pick isabelle_version based on build_log database;
wenzelm
parents:
65781
diff
changeset
|
763 |
val table2 = meta_info_table |
|
d3d5cb2d6866
pick isabelle_version based on build_log database;
wenzelm
parents:
65781
diff
changeset
|
764 |
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
|
765 |
|
|
d3d5cb2d6866
pick isabelle_version based on build_log database;
wenzelm
parents:
65781
diff
changeset
|
766 |
val columns = |
| 66858 | 767 |
table1.columns.map(c => c(table1)) ::: |
768 |
List(known.copy(expr = log_name(aux_table).defined)) |
|
|
65783
d3d5cb2d6866
pick isabelle_version based on build_log database;
wenzelm
parents:
65781
diff
changeset
|
769 |
SQL.select(columns, distinct = true) + |
|
d3d5cb2d6866
pick isabelle_version based on build_log database;
wenzelm
parents:
65781
diff
changeset
|
770 |
table1.query_named + SQL.join_outer + aux_table.query_named + |
| 66858 | 771 |
" ON " + version(table1) + " = " + version(aux_table) + |
|
66880
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66874
diff
changeset
|
772 |
" ORDER BY " + pull_date(afp)(table1) + " DESC" |
|
65783
d3d5cb2d6866
pick isabelle_version based on build_log database;
wenzelm
parents:
65781
diff
changeset
|
773 |
} |
|
d3d5cb2d6866
pick isabelle_version based on build_log database;
wenzelm
parents:
65781
diff
changeset
|
774 |
|
| 65724 | 775 |
|
776 |
/* universal view on main data */ |
|
777 |
||
| 75393 | 778 |
val universal_table: SQL.Table = {
|
|
66880
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66874
diff
changeset
|
779 |
val afp_pull_date = pull_date(afp = true) |
|
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66874
diff
changeset
|
780 |
val version1 = Prop.isabelle_version |
|
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66874
diff
changeset
|
781 |
val version2 = Prop.afp_version |
| 65724 | 782 |
val table1 = meta_info_table |
|
66880
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66874
diff
changeset
|
783 |
val table2 = pull_date_table(afp = true) |
|
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66874
diff
changeset
|
784 |
val table3 = pull_date_table() |
| 65724 | 785 |
|
|
66880
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66874
diff
changeset
|
786 |
val a_columns = log_name :: afp_pull_date :: table1.columns.tail |
|
65850
5414c14c3984
clarified universal table: include ml_statistics;
wenzelm
parents:
65804
diff
changeset
|
787 |
val a_table = |
|
5414c14c3984
clarified universal table: include ml_statistics;
wenzelm
parents:
65804
diff
changeset
|
788 |
SQL.Table("a", a_columns,
|
|
66880
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66874
diff
changeset
|
789 |
SQL.select(List(log_name, afp_pull_date) ::: table1.columns.tail.map(_.apply(table1))) + |
|
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66874
diff
changeset
|
790 |
table1 + SQL.join_outer + table2 + |
|
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66874
diff
changeset
|
791 |
" ON " + version1(table1) + " = " + version1(table2) + |
|
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66874
diff
changeset
|
792 |
" AND " + version2(table1) + " = " + version2(table2)) |
| 65724 | 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 |
|
|
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66874
diff
changeset
|
809 |
SQL.Table("isabelle_build_log", c_columns ::: List(ml_statistics),
|
| 65724 | 810 |
{
|
|
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)) + |
|
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66874
diff
changeset
|
812 |
c_table.query_named + SQL.join_outer + ml_statistics_table + |
|
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66874
diff
changeset
|
813 |
" ON " + log_name(c_table) + " = " + log_name(ml_statistics_table) + |
|
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66874
diff
changeset
|
814 |
" AND " + session_name(c_table) + " = " + session_name(ml_statistics_table) |
| 65724 | 815 |
}) |
816 |
} |
|
| 65694 | 817 |
} |
818 |
||
819 |
||
820 |
/* database access */ |
|
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 | 824 |
|
| 75393 | 825 |
class Store private[Build_Log](options: Options, val cache: XML.Cache) {
|
| 65595 | 826 |
def open_database( |
827 |
user: String = options.string("build_log_database_user"),
|
|
828 |
password: String = options.string("build_log_database_password"),
|
|
829 |
database: String = options.string("build_log_database_name"),
|
|
830 |
host: String = options.string("build_log_database_host"),
|
|
831 |
port: Int = options.int("build_log_database_port"),
|
|
832 |
ssh_host: String = options.string("build_log_ssh_host"),
|
|
833 |
ssh_user: String = options.string("build_log_ssh_user"),
|
|
| 75393 | 834 |
ssh_port: Int = options.int("build_log_ssh_port")
|
835 |
): PostgreSQL.Database = {
|
|
| 65595 | 836 |
PostgreSQL.open_database( |
837 |
user = user, password = password, database = database, host = host, port = port, |
|
838 |
ssh = |
|
839 |
if (ssh_host == "") None |
|
| 73025 | 840 |
else Some(SSH.open_session(options, host = ssh_host, user = ssh_user, port = ssh_port)), |
|
65636
df804cdba5f9
ssh_close for proper termination after use of database;
wenzelm
parents:
65633
diff
changeset
|
841 |
ssh_close = true) |
| 65595 | 842 |
} |
| 65599 | 843 |
|
| 73340 | 844 |
def update_database( |
| 75393 | 845 |
db: PostgreSQL.Database, dirs: List[Path], ml_statistics: Boolean = false): Unit = {
|
|
69299
2fd070377c99
clarified default (amending 72a9860f8602): avoid implicit change of File.find_files (it can have bad effects e.g. on "isabelle update_cartouches");
wenzelm
parents:
68169
diff
changeset
|
846 |
val log_files = |
|
2fd070377c99
clarified default (amending 72a9860f8602): avoid implicit change of File.find_files (it can have bad effects e.g. on "isabelle update_cartouches");
wenzelm
parents:
68169
diff
changeset
|
847 |
dirs.flatMap(dir => |
|
2fd070377c99
clarified default (amending 72a9860f8602): avoid implicit change of File.find_files (it can have bad effects e.g. on "isabelle update_cartouches");
wenzelm
parents:
68169
diff
changeset
|
848 |
File.find_files(dir.file, pred = Log_File.is_log(_), follow_links = true)) |
|
2fd070377c99
clarified default (amending 72a9860f8602): avoid implicit change of File.find_files (it can have bad effects e.g. on "isabelle update_cartouches");
wenzelm
parents:
68169
diff
changeset
|
849 |
write_info(db, log_files, ml_statistics = ml_statistics) |
| 65694 | 850 |
|
|
66863
6acd1a2bd146
clarified afp_pull_date: both repository versions are relevant;
wenzelm
parents:
66858
diff
changeset
|
851 |
db.create_view(Data.pull_date_table()) |
|
6acd1a2bd146
clarified afp_pull_date: both repository versions are relevant;
wenzelm
parents:
66858
diff
changeset
|
852 |
db.create_view(Data.pull_date_table(afp = true)) |
| 65724 | 853 |
db.create_view(Data.universal_table) |
| 65694 | 854 |
} |
855 |
||
| 75393 | 856 |
def snapshot_database( |
857 |
db: PostgreSQL.Database, |
|
858 |
sqlite_database: Path, |
|
859 |
days: Int = 100, |
|
860 |
ml_statistics: Boolean = false |
|
861 |
): Unit = {
|
|
| 72375 | 862 |
Isabelle_System.make_directory(sqlite_database.dir) |
| 65694 | 863 |
sqlite_database.file.delete |
864 |
||
| 75394 | 865 |
using(SQLite.open_database(sqlite_database)) { db2 =>
|
| 65694 | 866 |
db.transaction {
|
867 |
db2.transaction {
|
|
| 65705 | 868 |
// main content |
869 |
db2.create_table(Data.meta_info_table) |
|
870 |
db2.create_table(Data.sessions_table) |
|
|
66874
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
871 |
db2.create_table(Data.theories_table) |
| 65705 | 872 |
db2.create_table(Data.ml_statistics_table) |
873 |
||
874 |
val recent_log_names = |
|
| 65781 | 875 |
db.using_statement(Data.select_recent_log_names(days))(stmt => |
| 65779 | 876 |
stmt.execute_query().iterator(_.string(Data.log_name)).toList) |
| 65705 | 877 |
|
878 |
for (log_name <- recent_log_names) {
|
|
879 |
read_meta_info(db, log_name).foreach(meta_info => |
|
880 |
update_meta_info(db2, log_name, meta_info)) |
|
881 |
||
882 |
update_sessions(db2, log_name, read_build_info(db, log_name)) |
|
883 |
||
| 65856 | 884 |
if (ml_statistics) {
|
885 |
update_ml_statistics(db2, log_name, |
|
886 |
read_build_info(db, log_name, ml_statistics = true)) |
|
887 |
} |
|
| 65705 | 888 |
} |
889 |
||
890 |
// pull_date |
|
| 75393 | 891 |
for (afp <- List(false, true)) {
|
|
66880
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66874
diff
changeset
|
892 |
val afp_rev = if (afp) Some("") else None
|
|
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66874
diff
changeset
|
893 |
val table = Data.pull_date_table(afp) |
| 65694 | 894 |
db2.create_table(table) |
| 75394 | 895 |
db2.using_statement(table.insert()) { stmt2 =>
|
|
66880
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66874
diff
changeset
|
896 |
db.using_statement( |
| 75394 | 897 |
Data.recent_pull_date_table(days, afp_rev = afp_rev).query) { stmt =>
|
| 65740 | 898 |
val res = stmt.execute_query() |
899 |
while (res.next()) {
|
|
| 65748 | 900 |
for ((c, i) <- table.columns.zipWithIndex) {
|
901 |
stmt2.string(i + 1) = res.get_string(c) |
|
902 |
} |
|
| 65740 | 903 |
stmt2.execute() |
| 65694 | 904 |
} |
| 75394 | 905 |
} |
906 |
} |
|
| 65709 | 907 |
} |
| 65705 | 908 |
|
909 |
// full view |
|
| 65724 | 910 |
db2.create_view(Data.universal_table) |
| 65694 | 911 |
} |
912 |
} |
|
| 65708 | 913 |
db2.rebuild |
| 75394 | 914 |
} |
| 65694 | 915 |
} |
916 |
||
| 65688 | 917 |
def domain(db: SQL.Database, table: SQL.Table, column: SQL.Column): Set[String] = |
| 65698 | 918 |
db.using_statement(table.select(List(column), distinct = true))(stmt => |
| 65740 | 919 |
stmt.execute_query().iterator(_.string(column)).toSet) |
| 65688 | 920 |
|
| 75393 | 921 |
def update_meta_info(db: SQL.Database, log_name: String, meta_info: Meta_Info): Unit = {
|
| 65694 | 922 |
val table = Data.meta_info_table |
| 75394 | 923 |
db.using_statement(db.insert_permissive(table)) { stmt =>
|
| 65748 | 924 |
stmt.string(1) = log_name |
|
65703
cead65c19f2e
more direct insert_permissive statement, which avoids somewhat fragile nested transactions;
wenzelm
parents:
65702
diff
changeset
|
925 |
for ((c, i) <- table.columns.tail.zipWithIndex) {
|
|
cead65c19f2e
more direct insert_permissive statement, which avoids somewhat fragile nested transactions;
wenzelm
parents:
65702
diff
changeset
|
926 |
if (c.T == SQL.Type.Date) |
| 65748 | 927 |
stmt.date(i + 2) = meta_info.get_date(c) |
|
65703
cead65c19f2e
more direct insert_permissive statement, which avoids somewhat fragile nested transactions;
wenzelm
parents:
65702
diff
changeset
|
928 |
else |
| 65748 | 929 |
stmt.string(i + 2) = meta_info.get(c) |
|
65703
cead65c19f2e
more direct insert_permissive statement, which avoids somewhat fragile nested transactions;
wenzelm
parents:
65702
diff
changeset
|
930 |
} |
|
cead65c19f2e
more direct insert_permissive statement, which avoids somewhat fragile nested transactions;
wenzelm
parents:
65702
diff
changeset
|
931 |
stmt.execute() |
| 75394 | 932 |
} |
| 65600 | 933 |
} |
934 |
||
| 75393 | 935 |
def update_sessions(db: SQL.Database, log_name: String, build_info: Build_Info): Unit = {
|
| 65694 | 936 |
val table = Data.sessions_table |
| 75394 | 937 |
db.using_statement(db.insert_permissive(table)) { stmt =>
|
|
66874
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
938 |
val sessions = |
|
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
939 |
if (build_info.sessions.isEmpty) Build_Info.sessions_dummy |
|
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
940 |
else build_info.sessions |
|
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
941 |
for ((session_name, session) <- sessions) {
|
| 65748 | 942 |
stmt.string(1) = log_name |
943 |
stmt.string(2) = session_name |
|
| 65853 | 944 |
stmt.string(3) = proper_string(session.chapter) |
| 65748 | 945 |
stmt.string(4) = session.proper_groups |
946 |
stmt.int(5) = session.threads |
|
947 |
stmt.long(6) = session.timing.elapsed.proper_ms |
|
948 |
stmt.long(7) = session.timing.cpu.proper_ms |
|
949 |
stmt.long(8) = session.timing.gc.proper_ms |
|
950 |
stmt.double(9) = session.timing.factor |
|
951 |
stmt.long(10) = session.ml_timing.elapsed.proper_ms |
|
952 |
stmt.long(11) = session.ml_timing.cpu.proper_ms |
|
953 |
stmt.long(12) = session.ml_timing.gc.proper_ms |
|
954 |
stmt.double(13) = session.ml_timing.factor |
|
955 |
stmt.long(14) = session.heap_size |
|
956 |
stmt.string(15) = session.status.map(_.toString) |
|
|
73031
f93f0597f4fb
clarified signature: absorb XZ.Cache into XML.Cache;
wenzelm
parents:
73025
diff
changeset
|
957 |
stmt.bytes(16) = compress_errors(session.errors, cache = cache.xz) |
| 66913 | 958 |
stmt.string(17) = session.sources |
|
65703
cead65c19f2e
more direct insert_permissive statement, which avoids somewhat fragile nested transactions;
wenzelm
parents:
65702
diff
changeset
|
959 |
stmt.execute() |
|
cead65c19f2e
more direct insert_permissive statement, which avoids somewhat fragile nested transactions;
wenzelm
parents:
65702
diff
changeset
|
960 |
} |
| 75394 | 961 |
} |
| 65642 | 962 |
} |
963 |
||
| 75393 | 964 |
def update_theories(db: SQL.Database, log_name: String, build_info: Build_Info): Unit = {
|
|
66874
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
965 |
val table = Data.theories_table |
| 75394 | 966 |
db.using_statement(db.insert_permissive(table)) { stmt =>
|
|
66874
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
967 |
val sessions = |
|
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
968 |
if (build_info.sessions.forall({ case (_, session) => session.theory_timings.isEmpty }))
|
|
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
969 |
Build_Info.sessions_dummy |
|
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
970 |
else build_info.sessions |
|
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
971 |
for {
|
|
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
972 |
(session_name, session) <- sessions |
|
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
973 |
(theory_name, timing) <- session.theory_timings |
|
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
974 |
} {
|
|
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
975 |
stmt.string(1) = log_name |
|
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
976 |
stmt.string(2) = session_name |
|
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
977 |
stmt.string(3) = theory_name |
|
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
978 |
stmt.long(4) = timing.elapsed.ms |
|
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
979 |
stmt.long(5) = timing.cpu.ms |
|
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
980 |
stmt.long(6) = timing.gc.ms |
|
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
981 |
stmt.execute() |
|
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
982 |
} |
| 75394 | 983 |
} |
|
66874
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
984 |
} |
|
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
985 |
|
| 75393 | 986 |
def update_ml_statistics(db: SQL.Database, log_name: String, build_info: Build_Info): Unit = {
|
| 65694 | 987 |
val table = Data.ml_statistics_table |
| 75394 | 988 |
db.using_statement(db.insert_permissive(table)) { stmt =>
|
|
65703
cead65c19f2e
more direct insert_permissive statement, which avoids somewhat fragile nested transactions;
wenzelm
parents:
65702
diff
changeset
|
989 |
val ml_stats: List[(String, Option[Bytes])] = |
|
cead65c19f2e
more direct insert_permissive statement, which avoids somewhat fragile nested transactions;
wenzelm
parents:
65702
diff
changeset
|
990 |
Par_List.map[(String, Session_Entry), (String, Option[Bytes])]( |
|
73031
f93f0597f4fb
clarified signature: absorb XZ.Cache into XML.Cache;
wenzelm
parents:
73025
diff
changeset
|
991 |
{ case (a, b) => (a, Properties.compress(b.ml_statistics, cache = cache.xz).proper) },
|
|
65703
cead65c19f2e
more direct insert_permissive statement, which avoids somewhat fragile nested transactions;
wenzelm
parents:
65702
diff
changeset
|
992 |
build_info.sessions.iterator.filter(p => p._2.ml_statistics.nonEmpty).toList) |
|
cead65c19f2e
more direct insert_permissive statement, which avoids somewhat fragile nested transactions;
wenzelm
parents:
65702
diff
changeset
|
993 |
val entries = if (ml_stats.nonEmpty) ml_stats else List("" -> None)
|
|
cead65c19f2e
more direct insert_permissive statement, which avoids somewhat fragile nested transactions;
wenzelm
parents:
65702
diff
changeset
|
994 |
for ((session_name, ml_statistics) <- entries) {
|
| 65748 | 995 |
stmt.string(1) = log_name |
996 |
stmt.string(2) = session_name |
|
997 |
stmt.bytes(3) = ml_statistics |
|
|
65703
cead65c19f2e
more direct insert_permissive statement, which avoids somewhat fragile nested transactions;
wenzelm
parents:
65702
diff
changeset
|
998 |
stmt.execute() |
|
cead65c19f2e
more direct insert_permissive statement, which avoids somewhat fragile nested transactions;
wenzelm
parents:
65702
diff
changeset
|
999 |
} |
| 75394 | 1000 |
} |
|
65645
2c704ae04db1
clarified database layout: bulky ml_statistics are stored/retrieved separately;
wenzelm
parents:
65643
diff
changeset
|
1001 |
} |
|
2c704ae04db1
clarified database layout: bulky ml_statistics are stored/retrieved separately;
wenzelm
parents:
65643
diff
changeset
|
1002 |
|
| 75393 | 1003 |
def write_info(db: SQL.Database, files: List[JFile], ml_statistics: Boolean = false): Unit = {
|
1004 |
abstract class Table_Status(table: SQL.Table) {
|
|
| 65688 | 1005 |
db.create_table(table) |
| 65694 | 1006 |
private var known: Set[String] = domain(db, table, Data.log_name) |
| 65688 | 1007 |
|
| 65642 | 1008 |
def required(file: JFile): Boolean = !known(Log_File.plain_name(file.getName)) |
| 65705 | 1009 |
|
1010 |
def update_db(db: SQL.Database, log_file: Log_File): Unit |
|
| 75393 | 1011 |
def update(log_file: Log_File): Unit = {
|
| 65642 | 1012 |
if (!known(log_file.name)) {
|
1013 |
update_db(db, log_file) |
|
1014 |
known += log_file.name |
|
| 65618 | 1015 |
} |
|
65614
325801edb37d
clarified transaction boundaries: more robust incremental write operations;
wenzelm
parents:
65613
diff
changeset
|
1016 |
} |
| 65605 | 1017 |
} |
| 65642 | 1018 |
val status = |
1019 |
List( |
|
| 65705 | 1020 |
new Table_Status(Data.meta_info_table) {
|
1021 |
override def update_db(db: SQL.Database, log_file: Log_File): Unit = |
|
1022 |
update_meta_info(db, log_file.name, log_file.parse_meta_info()) |
|
1023 |
}, |
|
1024 |
new Table_Status(Data.sessions_table) {
|
|
1025 |
override def update_db(db: SQL.Database, log_file: Log_File): Unit = |
|
1026 |
update_sessions(db, log_file.name, log_file.parse_build_info()) |
|
1027 |
}, |
|
|
66874
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
1028 |
new Table_Status(Data.theories_table) {
|
|
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
1029 |
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
|
1030 |
update_theories(db, log_file.name, log_file.parse_build_info()) |
|
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66873
diff
changeset
|
1031 |
}, |
| 65705 | 1032 |
new Table_Status(Data.ml_statistics_table) {
|
1033 |
override def update_db(db: SQL.Database, log_file: Log_File): Unit = |
|
1034 |
if (ml_statistics) {
|
|
1035 |
update_ml_statistics(db, log_file.name, |
|
1036 |
log_file.parse_build_info(ml_statistics = true)) |
|
1037 |
} |
|
1038 |
}) |
|
| 65642 | 1039 |
|
| 67743 | 1040 |
for (file_group <- |
1041 |
files.filter(file => status.exists(_.required(file))). |
|
| 75393 | 1042 |
grouped(options.int("build_log_transaction_size") max 1)) {
|
| 71621 | 1043 |
val log_files = Par_List.map[JFile, Log_File](Log_File.apply, file_group) |
| 65642 | 1044 |
db.transaction { log_files.foreach(log_file => status.foreach(_.update(log_file))) }
|
1045 |
} |
|
| 65605 | 1046 |
} |
1047 |
||
| 75393 | 1048 |
def read_meta_info(db: SQL.Database, log_name: String): Option[Meta_Info] = {
|
| 65694 | 1049 |
val table = Data.meta_info_table |
| 65642 | 1050 |
val columns = table.columns.tail |
| 75394 | 1051 |
db.using_statement(table.select(columns, Data.log_name.where_equal(log_name))) { stmt =>
|
| 65740 | 1052 |
val res = stmt.execute_query() |
| 73344 | 1053 |
if (!res.next()) None |
| 65621 | 1054 |
else {
|
1055 |
val results = |
|
| 65642 | 1056 |
columns.map(c => c.name -> |
| 65621 | 1057 |
(if (c.T == SQL.Type.Date) |
| 65740 | 1058 |
res.get_date(c).map(Log_File.Date_Format(_)) |
| 65621 | 1059 |
else |
| 65740 | 1060 |
res.get_string(c))) |
| 65621 | 1061 |
val n = Prop.all_props.length |
1062 |
val props = for ((x, Some(y)) <- results.take(n)) yield (x, y) |
|
1063 |
val settings = for ((x, Some(y)) <- results.drop(n)) yield (x, y) |
|
1064 |
Some(Meta_Info(props, settings)) |
|
1065 |
} |
|
| 75394 | 1066 |
} |
| 65621 | 1067 |
} |
1068 |
||
1069 |
def read_build_info( |
|
| 65629 | 1070 |
db: SQL.Database, |
1071 |
log_name: String, |
|
1072 |
session_names: List[String] = Nil, |
|
| 75393 | 1073 |
ml_statistics: Boolean = false): Build_Info = {
|
| 65694 | 1074 |
val table1 = Data.sessions_table |
1075 |
val table2 = Data.ml_statistics_table |
|
| 65629 | 1076 |
|
|
65645
2c704ae04db1
clarified database layout: bulky ml_statistics are stored/retrieved separately;
wenzelm
parents:
65643
diff
changeset
|
1077 |
val where_log_name = |
| 65699 | 1078 |
Data.log_name(table1).where_equal(log_name) + " AND " + |
| 65701 | 1079 |
Data.session_name(table1) + " <> ''" |
| 65621 | 1080 |
val where = |
|
65645
2c704ae04db1
clarified database layout: bulky ml_statistics are stored/retrieved separately;
wenzelm
parents:
65643
diff
changeset
|
1081 |
if (session_names.isEmpty) where_log_name |
| 65804 | 1082 |
else where_log_name + " AND " + SQL.member(Data.session_name(table1).ident, session_names) |
| 65629 | 1083 |
|
|
65645
2c704ae04db1
clarified database layout: bulky ml_statistics are stored/retrieved separately;
wenzelm
parents:
65643
diff
changeset
|
1084 |
val columns1 = table1.columns.tail.map(_.apply(table1)) |
|
2c704ae04db1
clarified database layout: bulky ml_statistics are stored/retrieved separately;
wenzelm
parents:
65643
diff
changeset
|
1085 |
val (columns, from) = |
|
2c704ae04db1
clarified database layout: bulky ml_statistics are stored/retrieved separately;
wenzelm
parents:
65643
diff
changeset
|
1086 |
if (ml_statistics) {
|
| 65694 | 1087 |
val columns = columns1 ::: List(Data.ml_statistics(table2)) |
| 65668 | 1088 |
val join = |
| 73342 | 1089 |
table1.toString + SQL.join_outer + table2 + " ON " + |
| 65738 | 1090 |
Data.log_name(table1) + " = " + Data.log_name(table2) + " AND " + |
1091 |
Data.session_name(table1) + " = " + Data.session_name(table2) |
|
| 65668 | 1092 |
(columns, SQL.enclose(join)) |
|
65645
2c704ae04db1
clarified database layout: bulky ml_statistics are stored/retrieved separately;
wenzelm
parents:
65643
diff
changeset
|
1093 |
} |
| 65695 | 1094 |
else (columns1, table1.ident) |
|
65645
2c704ae04db1
clarified database layout: bulky ml_statistics are stored/retrieved separately;
wenzelm
parents:
65643
diff
changeset
|
1095 |
|
| 65621 | 1096 |
val sessions = |
| 75394 | 1097 |
db.using_statement(SQL.select(columns) + from + " " + where) { stmt =>
|
1098 |
stmt.execute_query().iterator({ res =>
|
|
| 65740 | 1099 |
val session_name = res.string(Data.session_name) |
| 65626 | 1100 |
val session_entry = |
1101 |
Session_Entry( |
|
| 65740 | 1102 |
chapter = res.string(Data.chapter), |
1103 |
groups = split_lines(res.string(Data.groups)), |
|
1104 |
threads = res.get_int(Data.threads), |
|
| 65741 | 1105 |
timing = res.timing(Data.timing_elapsed, Data.timing_cpu, Data.timing_gc), |
| 65626 | 1106 |
ml_timing = |
| 65741 | 1107 |
res.timing(Data.ml_timing_elapsed, Data.ml_timing_cpu, Data.ml_timing_gc), |
| 66913 | 1108 |
sources = res.get_string(Data.sources), |
| 65740 | 1109 |
heap_size = res.get_long(Data.heap_size), |
| 71621 | 1110 |
status = res.get_string(Data.status).map(Session_Status.withName), |
| 73033 | 1111 |
errors = uncompress_errors(res.bytes(Data.errors), cache = cache), |
| 65629 | 1112 |
ml_statistics = |
| 68018 | 1113 |
if (ml_statistics) {
|
|
73031
f93f0597f4fb
clarified signature: absorb XZ.Cache into XML.Cache;
wenzelm
parents:
73025
diff
changeset
|
1114 |
Properties.uncompress(res.bytes(Data.ml_statistics), cache = cache) |
| 68018 | 1115 |
} |
| 65629 | 1116 |
else Nil) |
| 65626 | 1117 |
session_name -> session_entry |
| 65621 | 1118 |
}).toMap |
| 75394 | 1119 |
} |
| 65621 | 1120 |
Build_Info(sessions) |
1121 |
} |
|
| 65595 | 1122 |
} |
| 64045 | 1123 |
} |