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