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