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