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