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