author | wenzelm |
Sat, 03 Mar 2018 12:54:22 +0100 | |
changeset 67751 | 361d41701de0 |
parent 67750 | 58a33c568464 |
child 67752 | 636f633552a3 |
permissions | -rw-r--r-- |
64148 | 1 |
/* Title: Pure/Admin/isabelle_cronjob.scala |
2 |
Author: Makarius |
|
3 |
||
4 |
Main entry point for administrative cronjob at TUM. |
|
5 |
*/ |
|
6 |
||
7 |
package isabelle |
|
8 |
||
9 |
||
64170 | 10 |
import scala.annotation.tailrec |
11 |
import scala.collection.mutable |
|
12 |
||
13 |
||
64148 | 14 |
object Isabelle_Cronjob |
15 |
{ |
|
66897 | 16 |
/* global resources: owned by main cronjob */ |
64153
769791954872
some timing and logging, similar to old isatest.log;
wenzelm
parents:
64148
diff
changeset
|
17 |
|
769791954872
some timing and logging, similar to old isatest.log;
wenzelm
parents:
64148
diff
changeset
|
18 |
val main_dir = Path.explode("~/cronjob") |
64194
b5ada7dcceaa
integrity test of build_history vs. build_history_base;
wenzelm
parents:
64193
diff
changeset
|
19 |
val main_state_file = main_dir + Path.explode("run/main.state") |
64219 | 20 |
val current_log = main_dir + Path.explode("run/main.log") // owned by log service |
21 |
val cumulative_log = main_dir + Path.explode("log/main.log") // owned by log service |
|
64153
769791954872
some timing and logging, similar to old isatest.log;
wenzelm
parents:
64148
diff
changeset
|
22 |
|
64231
dbc8294c75d3
added remote_build_history tasks: parallel on several remote hosts;
wenzelm
parents:
64220
diff
changeset
|
23 |
val isabelle_repos = main_dir + Path.explode("isabelle") |
dbc8294c75d3
added remote_build_history tasks: parallel on several remote hosts;
wenzelm
parents:
64220
diff
changeset
|
24 |
val isabelle_repos_test = main_dir + Path.explode("isabelle-test") |
dbc8294c75d3
added remote_build_history tasks: parallel on several remote hosts;
wenzelm
parents:
64220
diff
changeset
|
25 |
val afp_repos = main_dir + Path.explode("AFP") |
64236
358f9ff08681
discontinued somewhat pointless cronjob.options -- compile-time constants are sufficient;
wenzelm
parents:
64235
diff
changeset
|
26 |
|
66896 | 27 |
val build_log_dirs = |
28 |
List(Path.explode("~/log"), Path.explode("~/afp/log"), Path.explode("~/cronjob/log")) |
|
29 |
||
64153
769791954872
some timing and logging, similar to old isatest.log;
wenzelm
parents:
64148
diff
changeset
|
30 |
|
64192 | 31 |
|
32 |
/** particular tasks **/ |
|
33 |
||
67751 | 34 |
/* init and identify Isabelle + AFP repository snapshots */ |
64192 | 35 |
|
67751 | 36 |
private val init = |
37 |
Logger_Task("init", logger => |
|
66859 | 38 |
{ |
39 |
Isabelle_Devel.make_index() |
|
65771 | 40 |
|
66859 | 41 |
val rev = Mercurial.repository(isabelle_repos).id() |
42 |
val afp_rev = Mercurial.setup_repository(AFP.repos_source, afp_repos).id() |
|
64192 | 43 |
|
66859 | 44 |
File.write(logger.log_dir + Build_Log.log_filename("isabelle_identify", logger.start_date), |
45 |
Build_Log.Identify.content(logger.start_date, Some(rev), Some(afp_rev))) |
|
67751 | 46 |
}) |
47 |
||
48 |
||
49 |
/* build release */ |
|
50 |
||
51 |
private val build_release = |
|
52 |
Logger_Task("build_release", logger => |
|
53 |
{ |
|
54 |
val rev = Mercurial.repository(isabelle_repos).id() |
|
55 |
val afp_rev = Mercurial.repository(afp_repos).id() |
|
64405
81bac77929d9
just one task to identify Isabelle + AFP repository snapshots and build release;
wenzelm
parents:
64399
diff
changeset
|
56 |
|
66859 | 57 |
Isabelle_Devel.release_snapshot(rev = rev, afp_rev = afp_rev, |
58 |
parallel_jobs = 4, remote_mac = "macbroy31") |
|
59 |
}) |
|
64192 | 60 |
|
61 |
||
64194
b5ada7dcceaa
integrity test of build_history vs. build_history_base;
wenzelm
parents:
64193
diff
changeset
|
62 |
/* integrity test of build_history vs. build_history_base */ |
64193 | 63 |
|
64194
b5ada7dcceaa
integrity test of build_history vs. build_history_base;
wenzelm
parents:
64193
diff
changeset
|
64 |
private val build_history_base = |
64193 | 65 |
Logger_Task("build_history_base", logger => |
66 |
{ |
|
64251 | 67 |
val hg = |
68 |
Mercurial.setup_repository( |
|
69 |
File.standard_path(isabelle_repos), isabelle_repos_test) |
|
64194
b5ada7dcceaa
integrity test of build_history vs. build_history_base;
wenzelm
parents:
64193
diff
changeset
|
70 |
for { |
b5ada7dcceaa
integrity test of build_history vs. build_history_base;
wenzelm
parents:
64193
diff
changeset
|
71 |
(result, log_path) <- |
66861
f6676691ef8a
partition AFP sessions according to structure, which happens to cut it roughly into equal parts;
wenzelm
parents:
66860
diff
changeset
|
72 |
Build_History.build_history(logger.options, isabelle_repos_test, |
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66859
diff
changeset
|
73 |
rev = "build_history_base", fresh = true, build_args = List("HOL")) |
64194
b5ada7dcceaa
integrity test of build_history vs. build_history_base;
wenzelm
parents:
64193
diff
changeset
|
74 |
} { |
b5ada7dcceaa
integrity test of build_history vs. build_history_base;
wenzelm
parents:
64193
diff
changeset
|
75 |
result.check |
64482
43f6c28ff496
clarified File.move: target directory like File.copy;
wenzelm
parents:
64481
diff
changeset
|
76 |
File.move(log_path, logger.log_dir + log_path.base) |
64194
b5ada7dcceaa
integrity test of build_history vs. build_history_base;
wenzelm
parents:
64193
diff
changeset
|
77 |
} |
64193 | 78 |
}) |
79 |
||
80 |
||
64231
dbc8294c75d3
added remote_build_history tasks: parallel on several remote hosts;
wenzelm
parents:
64220
diff
changeset
|
81 |
/* remote build_history */ |
dbc8294c75d3
added remote_build_history tasks: parallel on several remote hosts;
wenzelm
parents:
64220
diff
changeset
|
82 |
|
66864 | 83 |
sealed case class Item( |
84 |
known: Boolean, |
|
85 |
isabelle_version: String, |
|
86 |
afp_version: Option[String], |
|
87 |
pull_date: Date) |
|
65783
d3d5cb2d6866
pick isabelle_version based on build_log database;
wenzelm
parents:
65771
diff
changeset
|
88 |
{ |
d3d5cb2d6866
pick isabelle_version based on build_log database;
wenzelm
parents:
65771
diff
changeset
|
89 |
def unknown: Boolean = !known |
66864 | 90 |
def versions: (String, Option[String]) = (isabelle_version, afp_version) |
91 |
||
92 |
def known_versions(rev: String, afp_rev: Option[String]): Boolean = |
|
93 |
known && rev != "" && isabelle_version == rev && |
|
94 |
(afp_rev.isEmpty || afp_rev.get != "" && afp_version == afp_rev.get) |
|
65783
d3d5cb2d6866
pick isabelle_version based on build_log database;
wenzelm
parents:
65771
diff
changeset
|
95 |
} |
d3d5cb2d6866
pick isabelle_version based on build_log database;
wenzelm
parents:
65771
diff
changeset
|
96 |
|
66864 | 97 |
def recent_items(db: SQL.Database, |
98 |
days: Int, rev: String, afp_rev: Option[String], sql: SQL.Source): List[Item] = |
|
65807 | 99 |
{ |
66880
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66879
diff
changeset
|
100 |
val afp = afp_rev.isDefined |
65807 | 101 |
val select = |
66864 | 102 |
Build_Log.Data.select_recent_versions( |
103 |
days = days, rev = rev, afp_rev = afp_rev, sql = "WHERE " + sql) |
|
65807 | 104 |
|
105 |
db.using_statement(select)(stmt => |
|
106 |
stmt.execute_query().iterator(res => |
|
107 |
{ |
|
108 |
val known = res.bool(Build_Log.Data.known) |
|
109 |
val isabelle_version = res.string(Build_Log.Prop.isabelle_version) |
|
66880
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66879
diff
changeset
|
110 |
val afp_version = if (afp) proper_string(res.string(Build_Log.Prop.afp_version)) else None |
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66879
diff
changeset
|
111 |
val pull_date = res.date(Build_Log.Data.pull_date(afp)) |
66864 | 112 |
Item(known, isabelle_version, afp_version, pull_date) |
65807 | 113 |
}).toList) |
114 |
} |
|
115 |
||
116 |
def unknown_runs(items: List[Item]): List[List[Item]] = |
|
117 |
{ |
|
118 |
val (run, rest) = Library.take_prefix[Item](_.unknown, items.dropWhile(_.known)) |
|
119 |
if (run.nonEmpty) run :: unknown_runs(rest) else Nil |
|
120 |
} |
|
121 |
||
64409
70c87ca55f2c
tuned signature -- more friendly for experimentation;
wenzelm
parents:
64405
diff
changeset
|
122 |
sealed case class Remote_Build( |
65764 | 123 |
description: String, |
64231
dbc8294c75d3
added remote_build_history tasks: parallel on several remote hosts;
wenzelm
parents:
64220
diff
changeset
|
124 |
host: String, |
dbc8294c75d3
added remote_build_history tasks: parallel on several remote hosts;
wenzelm
parents:
64220
diff
changeset
|
125 |
user: String = "", |
65594 | 126 |
port: Int = 0, |
67746 | 127 |
ssh_host: String = "", |
128 |
proxy_host: String = "", |
|
129 |
proxy_user: String = "", |
|
130 |
proxy_port: Int = 0, |
|
64294
303976a45afe
shared_home is default for classic isatest home setup;
wenzelm
parents:
64277
diff
changeset
|
131 |
shared_home: Boolean = true, |
65820 | 132 |
historic: Boolean = false, |
65789 | 133 |
history: Int = 0, |
65820 | 134 |
history_base: String = "build_history_base", |
64231
dbc8294c75d3
added remote_build_history tasks: parallel on several remote hosts;
wenzelm
parents:
64220
diff
changeset
|
135 |
options: String = "", |
65732 | 136 |
args: String = "", |
66864 | 137 |
afp: Boolean = false, |
66980 | 138 |
slow: Boolean = false, |
67075
eada9bd5fff2
avoid lxbroy7, which is presently inaccessible, but retain its build history in db queries;
wenzelm
parents:
67070
diff
changeset
|
139 |
more_hosts: List[String] = Nil, |
67080 | 140 |
detect: SQL.Source = "", |
141 |
active: Boolean = true) |
|
65732 | 142 |
{ |
67750 | 143 |
def ssh_session(context: SSH.Context): SSH.Session = |
144 |
context.open_session(host = proper_string(ssh_host) getOrElse host, user = user, port = port, |
|
145 |
proxy_host = proxy_host, proxy_user = proxy_user, proxy_port = proxy_port) |
|
146 |
||
65783
d3d5cb2d6866
pick isabelle_version based on build_log database;
wenzelm
parents:
65771
diff
changeset
|
147 |
def sql: SQL.Source = |
d3d5cb2d6866
pick isabelle_version based on build_log database;
wenzelm
parents:
65771
diff
changeset
|
148 |
Build_Log.Prop.build_engine + " = " + SQL.string(Build_History.engine) + " AND " + |
67075
eada9bd5fff2
avoid lxbroy7, which is presently inaccessible, but retain its build history in db queries;
wenzelm
parents:
67070
diff
changeset
|
149 |
SQL.member(Build_Log.Prop.build_host.ident, host :: more_hosts) + |
65783
d3d5cb2d6866
pick isabelle_version based on build_log database;
wenzelm
parents:
65771
diff
changeset
|
150 |
(if (detect == "") "" else " AND " + SQL.enclose(detect)) |
d3d5cb2d6866
pick isabelle_version based on build_log database;
wenzelm
parents:
65771
diff
changeset
|
151 |
|
65747 | 152 |
def profile: Build_Status.Profile = |
66980 | 153 |
Build_Status.Profile(description, history = history, afp = afp, slow = slow, sql = sql) |
65783
d3d5cb2d6866
pick isabelle_version based on build_log database;
wenzelm
parents:
65771
diff
changeset
|
154 |
|
66864 | 155 |
def pick( |
156 |
options: Options, |
|
157 |
rev: String = "", |
|
66865 | 158 |
filter: Item => Boolean = _ => true): Option[(String, Option[String])] = |
65747 | 159 |
{ |
66864 | 160 |
val afp_rev = if (afp) Some(Mercurial.repository(afp_repos).id()) else None |
161 |
||
65783
d3d5cb2d6866
pick isabelle_version based on build_log database;
wenzelm
parents:
65771
diff
changeset
|
162 |
val store = Build_Log.store(options) |
d3d5cb2d6866
pick isabelle_version based on build_log database;
wenzelm
parents:
65771
diff
changeset
|
163 |
using(store.open_database())(db => |
d3d5cb2d6866
pick isabelle_version based on build_log database;
wenzelm
parents:
65771
diff
changeset
|
164 |
{ |
66864 | 165 |
def pick_days(days: Int, gap: Int): Option[(String, Option[String])] = |
65810 | 166 |
{ |
66865 | 167 |
val items = recent_items(db, days, rev, afp_rev, sql).filter(filter) |
66007 | 168 |
def runs = unknown_runs(items).filter(run => run.length >= gap) |
65783
d3d5cb2d6866
pick isabelle_version based on build_log database;
wenzelm
parents:
65771
diff
changeset
|
169 |
|
66864 | 170 |
if (historic || items.exists(_.known_versions(rev, afp_rev))) { |
65810 | 171 |
val longest_run = |
172 |
(List.empty[Item] /: runs)({ case (item1, item2) => |
|
173 |
if (item1.length >= item2.length) item1 else item2 |
|
174 |
}) |
|
175 |
if (longest_run.isEmpty) None |
|
66864 | 176 |
else Some(longest_run(longest_run.length / 2).versions) |
65810 | 177 |
} |
66864 | 178 |
else if (rev != "") Some((rev, afp_rev)) |
179 |
else runs.flatten.headOption.map(_.versions) |
|
65783
d3d5cb2d6866
pick isabelle_version based on build_log database;
wenzelm
parents:
65771
diff
changeset
|
180 |
} |
65810 | 181 |
|
66007 | 182 |
pick_days(options.int("build_log_history") max history, 2) orElse |
183 |
pick_days(200, 5) orElse |
|
184 |
pick_days(2000, 1) |
|
65783
d3d5cb2d6866
pick isabelle_version based on build_log database;
wenzelm
parents:
65771
diff
changeset
|
185 |
}) |
65747 | 186 |
} |
65732 | 187 |
} |
64231
dbc8294c75d3
added remote_build_history tasks: parallel on several remote hosts;
wenzelm
parents:
64220
diff
changeset
|
188 |
|
65806 | 189 |
val remote_builds_old: List[Remote_Build] = |
190 |
List( |
|
67608 | 191 |
Remote_Build("AFP", "lxbroy7", |
192 |
args = "-N -X slow", |
|
193 |
afp = true, |
|
194 |
detect = Build_Log.Prop.build_tags + " = " + SQL.string("AFP")), |
|
66762 | 195 |
Remote_Build("Poly/ML 5.7 Linux", "lxbroy8", |
196 |
history_base = "37074e22e8be", |
|
197 |
options = "-m32 -B -M1x2,2 -t polyml-5.7 -i 'init_component /home/isabelle/contrib/polyml-5.7'", |
|
198 |
args = "-N -g timing", |
|
199 |
detect = Build_Log.Prop.build_tags + " = " + SQL.string("polyml-5.7") + " AND " + |
|
200 |
Build_Log.Settings.ML_OPTIONS + " <> " + SQL.string("-H 500")), |
|
66931 | 201 |
Remote_Build("Poly/ML 5.7.1 Linux", "lxbroy8", |
202 |
history_base = "a9d5b59c3e12", |
|
203 |
options = "-m32 -B -M1x2,2 -t polyml-5.7.1-pre2 -i 'init_component /home/isabelle/contrib/polyml-test-905dae2ebfda'", |
|
204 |
args = "-N -g timing", |
|
205 |
detect = |
|
206 |
Build_Log.Prop.build_tags + " = " + SQL.string("polyml-5.7.1-pre1") + " OR " + |
|
207 |
Build_Log.Prop.build_tags + " = " + SQL.string("polyml-5.7.1-pre2")), |
|
66762 | 208 |
Remote_Build("Poly/ML 5.7 Mac OS X", "macbroy2", |
209 |
history_base = "37074e22e8be", |
|
210 |
options = "-m32 -B -M1x4,4 -t polyml-5.7 -i 'init_component /home/isabelle/contrib/polyml-5.7'", |
|
211 |
args = "-a", |
|
212 |
detect = Build_Log.Prop.build_tags + " = " + SQL.string("polyml-5.7")), |
|
66931 | 213 |
Remote_Build("Poly/ML 5.7.1 Mac OS X", "macbroy2", |
214 |
history_base = "a9d5b59c3e12", |
|
215 |
options = "-m32 -B -M1x4,4 -t polyml-5.7.1-pre2 -i 'init_component /home/isabelle/contrib/polyml-test-905dae2ebfda'", |
|
216 |
args = "-a", |
|
217 |
detect = |
|
218 |
Build_Log.Prop.build_tags + " = " + SQL.string("polyml-5.7.1-pre1") + " OR " + |
|
219 |
Build_Log.Prop.build_tags + " = " + SQL.string("polyml-5.7.1-pre2")), |
|
65806 | 220 |
Remote_Build("Poly/ML test", "lxbroy8", |
65843
d547173212d2
proper init_settings for init_component (before generated ML_OPTIONS etc.);
wenzelm
parents:
65840
diff
changeset
|
221 |
options = "-m32 -B -M1x2,2 -t polyml-test -i 'init_component /home/isabelle/contrib/polyml-5.7-20170217'", |
65806 | 222 |
args = "-N -g timing", |
223 |
detect = Build_Log.Prop.build_tags + " = " + SQL.string("polyml-test")), |
|
224 |
Remote_Build("Mac OS X 10.8 Mountain Lion", "macbroy30", options = "-m32 -M2", args = "-a", |
|
225 |
detect = Build_Log.Prop.build_start + " < date '2017-03-03'")) |
|
226 |
||
227 |
||
66898
8b7c4679c05b
parallel remote_builds2 for the sake of "AFP slow" (with theoretical data race on build_log_dirs);
wenzelm
parents:
66897
diff
changeset
|
228 |
val remote_builds1: List[List[Remote_Build]] = |
65732 | 229 |
{ |
64231
dbc8294c75d3
added remote_build_history tasks: parallel on several remote hosts;
wenzelm
parents:
64220
diff
changeset
|
230 |
List( |
65764 | 231 |
List(Remote_Build("Linux A", "lxbroy9", |
65732 | 232 |
options = "-m32 -B -M1x2,2", args = "-N -g timing")), |
65820 | 233 |
List(Remote_Build("Linux B", "lxbroy10", historic = true, history = 90, |
65732 | 234 |
options = "-m32 -B -M1x4,2,4,6", args = "-N -g timing")), |
64351 | 235 |
List( |
67103
39cc38a06610
clarified description for mixed Mavericks / El Capitan system;
wenzelm
parents:
67089
diff
changeset
|
236 |
Remote_Build("Mac OS X", "macbroy2", |
65906 | 237 |
options = "-m32 -M8" + |
238 |
" -e ISABELLE_GHC=ghc -e ISABELLE_MLTON=mlton -e ISABELLE_OCAML=ocaml" + |
|
239 |
" -e ISABELLE_OCAMLC=ocamlc -e ISABELLE_SMLNJ=/mnt/nfsbroy/home/smlnj/bin/sml", |
|
65902 | 240 |
args = "-a", |
67080 | 241 |
detect = Build_Log.Prop.build_tags.undefined, |
67089
c96ee0eb0d5f
macbroy2 is back, still pretending to be on Mavericks for better comparison of performance;
wenzelm
parents:
67080
diff
changeset
|
242 |
history_base = "2c0f24e927dd"), |
67103
39cc38a06610
clarified description for mixed Mavericks / El Capitan system;
wenzelm
parents:
67089
diff
changeset
|
243 |
Remote_Build("Mac OS X, quick_and_dirty", "macbroy2", |
65732 | 244 |
options = "-m32 -M8 -t quick_and_dirty", args = "-a -o quick_and_dirty", |
67080 | 245 |
detect = Build_Log.Prop.build_tags + " = " + SQL.string("quick_and_dirty"), |
67089
c96ee0eb0d5f
macbroy2 is back, still pretending to be on Mavericks for better comparison of performance;
wenzelm
parents:
67080
diff
changeset
|
246 |
history_base = "2c0f24e927dd"), |
67103
39cc38a06610
clarified description for mixed Mavericks / El Capitan system;
wenzelm
parents:
67089
diff
changeset
|
247 |
Remote_Build("Mac OS X, skip_proofs", "macbroy2", |
65732 | 248 |
options = "-m32 -M8 -t skip_proofs", args = "-a -o skip_proofs", |
67080 | 249 |
detect = Build_Log.Prop.build_tags + " = " + SQL.string("skip_proofs"), |
67089
c96ee0eb0d5f
macbroy2 is back, still pretending to be on Mavericks for better comparison of performance;
wenzelm
parents:
67080
diff
changeset
|
250 |
history_base = "2c0f24e927dd")), |
65768 | 251 |
List( |
252 |
Remote_Build("Mac OS X 10.12 Sierra", "macbroy30", options = "-m32 -M2", args = "-a", |
|
253 |
detect = Build_Log.Prop.build_start + " > date '2017-03-03'")), |
|
254 |
List(Remote_Build("Mac OS X 10.10 Yosemite", "macbroy31", options = "-m32 -M2", args = "-a")), |
|
64351 | 255 |
List( |
66008 | 256 |
Remote_Build("Windows", "vmnipkow9", historic = true, history = 90, shared_home = false, |
65906 | 257 |
options = "-m32 -M4" + |
258 |
" -e ISABELLE_OCAML=ocaml -e ISABELLE_OCAMLC=ocamlc" + |
|
259 |
" -e ISABELLE_GHC=/usr/local/ghc-8.0.2/bin/ghc" + |
|
260 |
" -e ISABELLE_SMLNJ=/usr/local/smlnj-110.81/bin/sml", |
|
65902 | 261 |
args = "-a", |
65732 | 262 |
detect = Build_Log.Settings.ML_PLATFORM + " = " + SQL.string("x86-windows")), |
66008 | 263 |
Remote_Build("Windows", "vmnipkow9", historic = true, history = 90, shared_home = false, |
65906 | 264 |
options = "-m64 -M4" + |
265 |
" -e ISABELLE_OCAML=ocaml -e ISABELLE_OCAMLC=ocamlc" + |
|
266 |
" -e ISABELLE_GHC=/usr/local/ghc-8.0.2/bin/ghc" + |
|
267 |
" -e ISABELLE_SMLNJ=/usr/local/smlnj-110.81/bin/sml", |
|
65902 | 268 |
args = "-a", |
66868 | 269 |
detect = Build_Log.Settings.ML_PLATFORM + " = " + SQL.string("x86_64-windows"))), |
66864 | 270 |
) ::: |
271 |
{ |
|
67607 | 272 |
for { (n, hosts) <- List(1 -> List("lxbroy6"), 2 -> List("lxbroy8", "lxbroy5")) } |
66864 | 273 |
yield { |
67075
eada9bd5fff2
avoid lxbroy7, which is presently inaccessible, but retain its build history in db queries;
wenzelm
parents:
67070
diff
changeset
|
274 |
List(Remote_Build("AFP", host = hosts.head, more_hosts = hosts.tail, |
67568 | 275 |
options = "-m32 -M1x2 -t AFP -P" + n + |
276 |
" -e ISABELLE_GHC=ghc" + |
|
277 |
" -e ISABELLE_MLTON=mlton" + |
|
278 |
" -e ISABELLE_OCAML=ocaml -e ISABELLE_OCAMLC=ocamlc" + |
|
279 |
" -e ISABELLE_SMLNJ=/home/smlnj/bin/sml", |
|
66864 | 280 |
args = "-N -X slow", |
281 |
afp = true, |
|
282 |
detect = Build_Log.Prop.build_tags + " = " + SQL.string("AFP"))) |
|
283 |
} |
|
284 |
} |
|
65732 | 285 |
} |
64231
dbc8294c75d3
added remote_build_history tasks: parallel on several remote hosts;
wenzelm
parents:
64220
diff
changeset
|
286 |
|
66898
8b7c4679c05b
parallel remote_builds2 for the sake of "AFP slow" (with theoretical data race on build_log_dirs);
wenzelm
parents:
66897
diff
changeset
|
287 |
val remote_builds2: List[List[Remote_Build]] = |
8b7c4679c05b
parallel remote_builds2 for the sake of "AFP slow" (with theoretical data race on build_log_dirs);
wenzelm
parents:
66897
diff
changeset
|
288 |
List( |
8b7c4679c05b
parallel remote_builds2 for the sake of "AFP slow" (with theoretical data race on build_log_dirs);
wenzelm
parents:
66897
diff
changeset
|
289 |
List( |
8b7c4679c05b
parallel remote_builds2 for the sake of "AFP slow" (with theoretical data race on build_log_dirs);
wenzelm
parents:
66897
diff
changeset
|
290 |
Remote_Build("AFP slow", "lrzcloud1", shared_home = false, |
8b7c4679c05b
parallel remote_builds2 for the sake of "AFP slow" (with theoretical data race on build_log_dirs);
wenzelm
parents:
66897
diff
changeset
|
291 |
options = "-m64 -M6 -U30000 -s10 -t AFP", |
8b7c4679c05b
parallel remote_builds2 for the sake of "AFP slow" (with theoretical data race on build_log_dirs);
wenzelm
parents:
66897
diff
changeset
|
292 |
args = "-g slow", |
8b7c4679c05b
parallel remote_builds2 for the sake of "AFP slow" (with theoretical data race on build_log_dirs);
wenzelm
parents:
66897
diff
changeset
|
293 |
afp = true, |
66980 | 294 |
slow = true, |
66898
8b7c4679c05b
parallel remote_builds2 for the sake of "AFP slow" (with theoretical data race on build_log_dirs);
wenzelm
parents:
66897
diff
changeset
|
295 |
detect = Build_Log.Prop.build_tags + " = " + SQL.string("AFP")))) |
8b7c4679c05b
parallel remote_builds2 for the sake of "AFP slow" (with theoretical data race on build_log_dirs);
wenzelm
parents:
66897
diff
changeset
|
296 |
|
66864 | 297 |
private def remote_build_history( |
67070
85e6c1ff5be3
removed pointless user_home: no measurable impact;
wenzelm
parents:
67049
diff
changeset
|
298 |
rev: String, afp_rev: Option[String], i: Int, r: Remote_Build): Logger_Task = |
64294
303976a45afe
shared_home is default for classic isatest home setup;
wenzelm
parents:
64277
diff
changeset
|
299 |
{ |
303976a45afe
shared_home is default for classic isatest home setup;
wenzelm
parents:
64277
diff
changeset
|
300 |
val task_name = "build_history-" + r.host |
303976a45afe
shared_home is default for classic isatest home setup;
wenzelm
parents:
64277
diff
changeset
|
301 |
Logger_Task(task_name, logger => |
64231
dbc8294c75d3
added remote_build_history tasks: parallel on several remote hosts;
wenzelm
parents:
64220
diff
changeset
|
302 |
{ |
67750 | 303 |
using(r.ssh_session(logger.ssh_context))(ssh => |
304 |
{ |
|
305 |
val self_update = !r.shared_home |
|
306 |
val push_isabelle_home = self_update && Mercurial.is_repository(Path.explode("~~")) |
|
64348
4c253e84ae62
clarified push/pull chain: current ISABELLE_HOME may server as source for changes that are not published on isabelle_repos_source yet (e.g. isabelle-release branch);
wenzelm
parents:
64346
diff
changeset
|
307 |
|
67750 | 308 |
val results = |
309 |
Build_History.remote_build_history(ssh, |
|
310 |
isabelle_repos, |
|
311 |
isabelle_repos.ext(r.host), |
|
312 |
isabelle_identifier = "cronjob_build_history", |
|
313 |
self_update = self_update, |
|
314 |
push_isabelle_home = push_isabelle_home, |
|
315 |
rev = rev, |
|
316 |
afp_rev = afp_rev, |
|
317 |
options = |
|
318 |
" -N " + Bash.string(task_name) + (if (i < 0) "" else "_" + (i + 1).toString) + |
|
319 |
" -f " + r.options, |
|
320 |
args = "-o timeout=10800 " + r.args) |
|
64346 | 321 |
|
67750 | 322 |
for ((log_name, bytes) <- results) { |
323 |
logger.log(Date.now(), log_name) |
|
324 |
Bytes.write(logger.log_dir + Path.explode(log_name), bytes) |
|
325 |
} |
|
326 |
}) |
|
64231
dbc8294c75d3
added remote_build_history tasks: parallel on several remote hosts;
wenzelm
parents:
64220
diff
changeset
|
327 |
}) |
64294
303976a45afe
shared_home is default for classic isatest home setup;
wenzelm
parents:
64277
diff
changeset
|
328 |
} |
64231
dbc8294c75d3
added remote_build_history tasks: parallel on several remote hosts;
wenzelm
parents:
64220
diff
changeset
|
329 |
|
65747 | 330 |
val build_status_profiles: List[Build_Status.Profile] = |
66898
8b7c4679c05b
parallel remote_builds2 for the sake of "AFP slow" (with theoretical data race on build_log_dirs);
wenzelm
parents:
66897
diff
changeset
|
331 |
(remote_builds_old :: remote_builds1 ::: remote_builds2).flatten.map(_.profile) |
65747 | 332 |
|
65746 | 333 |
|
64192 | 334 |
|
335 |
/** task logging **/ |
|
64171 | 336 |
|
64193 | 337 |
sealed case class Logger_Task(name: String = "", body: Logger => Unit) |
64154 | 338 |
|
64257 | 339 |
class Log_Service private[Isabelle_Cronjob](progress: Progress, val ssh_context: SSH.Context) |
64171 | 340 |
{ |
64219 | 341 |
current_log.file.delete |
342 |
||
64171 | 343 |
private val thread: Consumer_Thread[String] = |
344 |
Consumer_Thread.fork("cronjob: logger", daemon = true)( |
|
345 |
consume = (text: String) => |
|
64219 | 346 |
{ // critical |
347 |
File.append(current_log, text + "\n") |
|
348 |
File.append(cumulative_log, text + "\n") |
|
64171 | 349 |
progress.echo(text) |
350 |
true |
|
351 |
}) |
|
352 |
||
353 |
def shutdown() { thread.shutdown() } |
|
354 |
||
355 |
val hostname = Isabelle_System.hostname() |
|
356 |
||
357 |
def log(date: Date, task_name: String, msg: String): Unit = |
|
64193 | 358 |
if (task_name != "") |
359 |
thread.send( |
|
360 |
"[" + Build_Log.print_date(date) + ", " + hostname + ", " + task_name + "]: " + msg) |
|
64171 | 361 |
|
362 |
def start_logger(start_date: Date, task_name: String): Logger = |
|
363 |
new Logger(this, start_date, task_name) |
|
64154 | 364 |
|
64171 | 365 |
def run_task(start_date: Date, task: Logger_Task) |
366 |
{ |
|
367 |
val logger = start_logger(start_date, task.name) |
|
368 |
val res = Exn.capture { task.body(logger) } |
|
369 |
val end_date = Date.now() |
|
370 |
val err = |
|
371 |
res match { |
|
372 |
case Exn.Res(_) => None |
|
64295 | 373 |
case Exn.Exn(exn) => |
67178 | 374 |
Output.writeln("Exception trace for " + quote(task.name) + ":") |
64397 | 375 |
exn.printStackTrace() |
66923 | 376 |
val first_line = split_lines(Exn.message(exn)).headOption getOrElse "exception" |
64295 | 377 |
Some(first_line) |
64171 | 378 |
} |
379 |
logger.log_end(end_date, err) |
|
380 |
} |
|
381 |
||
382 |
def fork_task(start_date: Date, task: Logger_Task): Task = |
|
383 |
new Task(task.name, run_task(start_date, task)) |
|
384 |
} |
|
385 |
||
386 |
class Logger private[Isabelle_Cronjob]( |
|
387 |
val log_service: Log_Service, val start_date: Date, val task_name: String) |
|
64162 | 388 |
{ |
64257 | 389 |
def ssh_context: SSH.Context = log_service.ssh_context |
65640 | 390 |
def options: Options = ssh_context.options |
64231
dbc8294c75d3
added remote_build_history tasks: parallel on several remote hosts;
wenzelm
parents:
64220
diff
changeset
|
391 |
|
64171 | 392 |
def log(date: Date, msg: String): Unit = log_service.log(date, task_name, msg) |
393 |
||
394 |
def log_end(end_date: Date, err: Option[String]) |
|
395 |
{ |
|
396 |
val elapsed_time = end_date.time - start_date.time |
|
397 |
val msg = |
|
398 |
(if (err.isEmpty) "finished" else "ERROR " + err.get) + |
|
64197 | 399 |
(if (elapsed_time.seconds < 3.0) "" else " (" + elapsed_time.message_hms + " elapsed time)") |
64171 | 400 |
log(end_date, msg) |
401 |
} |
|
402 |
||
64195 | 403 |
val log_dir: Path = main_dir + Build_Log.log_subdir(start_date) |
404 |
||
405 |
Isabelle_System.mkdirs(log_dir) |
|
64171 | 406 |
log(start_date, "started") |
407 |
} |
|
408 |
||
409 |
class Task private[Isabelle_Cronjob](name: String, body: => Unit) |
|
410 |
{ |
|
411 |
private val future: Future[Unit] = Future.thread("cronjob: " + name) { body } |
|
412 |
def is_finished: Boolean = future.is_finished |
|
64162 | 413 |
} |
64153
769791954872
some timing and logging, similar to old isatest.log;
wenzelm
parents:
64148
diff
changeset
|
414 |
|
64170 | 415 |
|
416 |
||
64153
769791954872
some timing and logging, similar to old isatest.log;
wenzelm
parents:
64148
diff
changeset
|
417 |
/** cronjob **/ |
769791954872
some timing and logging, similar to old isatest.log;
wenzelm
parents:
64148
diff
changeset
|
418 |
|
64187 | 419 |
def cronjob(progress: Progress, exclude_task: Set[String]) |
64153
769791954872
some timing and logging, similar to old isatest.log;
wenzelm
parents:
64148
diff
changeset
|
420 |
{ |
64171 | 421 |
/* soft lock */ |
64153
769791954872
some timing and logging, similar to old isatest.log;
wenzelm
parents:
64148
diff
changeset
|
422 |
|
769791954872
some timing and logging, similar to old isatest.log;
wenzelm
parents:
64148
diff
changeset
|
423 |
val still_running = |
769791954872
some timing and logging, similar to old isatest.log;
wenzelm
parents:
64148
diff
changeset
|
424 |
try { Some(File.read(main_state_file)) } |
769791954872
some timing and logging, similar to old isatest.log;
wenzelm
parents:
64148
diff
changeset
|
425 |
catch { case ERROR(_) => None } |
769791954872
some timing and logging, similar to old isatest.log;
wenzelm
parents:
64148
diff
changeset
|
426 |
|
769791954872
some timing and logging, similar to old isatest.log;
wenzelm
parents:
64148
diff
changeset
|
427 |
still_running match { |
64170 | 428 |
case None | Some("") => |
64153
769791954872
some timing and logging, similar to old isatest.log;
wenzelm
parents:
64148
diff
changeset
|
429 |
case Some(running) => |
769791954872
some timing and logging, similar to old isatest.log;
wenzelm
parents:
64148
diff
changeset
|
430 |
error("Isabelle cronjob appears to be still running: " + running) |
769791954872
some timing and logging, similar to old isatest.log;
wenzelm
parents:
64148
diff
changeset
|
431 |
} |
769791954872
some timing and logging, similar to old isatest.log;
wenzelm
parents:
64148
diff
changeset
|
432 |
|
64199 | 433 |
|
434 |
/* log service */ |
|
435 |
||
64257 | 436 |
val log_service = new Log_Service(progress, SSH.init_context(Options.init())) |
64154 | 437 |
|
64199 | 438 |
def run(start_date: Date, task: Logger_Task) { log_service.run_task(start_date, task) } |
439 |
||
440 |
def run_now(task: Logger_Task) { run(Date.now(), task) } |
|
64154 | 441 |
|
442 |
||
64199 | 443 |
/* structured tasks */ |
64184 | 444 |
|
64350
3af8566788e7
remote_builds has PAR-SEQ semantics of old isatest-makedist;
wenzelm
parents:
64348
diff
changeset
|
445 |
def SEQ(tasks: List[Logger_Task]): Logger_Task = Logger_Task(body = _ => |
64193 | 446 |
for (task <- tasks.iterator if !exclude_task(task.name) || task.name == "") |
64199 | 447 |
run_now(task)) |
64153
769791954872
some timing and logging, similar to old isatest.log;
wenzelm
parents:
64148
diff
changeset
|
448 |
|
64350
3af8566788e7
remote_builds has PAR-SEQ semantics of old isatest-makedist;
wenzelm
parents:
64348
diff
changeset
|
449 |
def PAR(tasks: List[Logger_Task]): Logger_Task = Logger_Task(body = _ => |
64170 | 450 |
{ |
64199 | 451 |
@tailrec def join(running: List[Task]) |
452 |
{ |
|
453 |
running.partition(_.is_finished) match { |
|
454 |
case (Nil, Nil) => |
|
455 |
case (Nil, _ :: _) => Thread.sleep(500); join(running) |
|
456 |
case (_ :: _, remaining) => join(remaining) |
|
457 |
} |
|
64170 | 458 |
} |
64199 | 459 |
val start_date = Date.now() |
460 |
val running = |
|
64350
3af8566788e7
remote_builds has PAR-SEQ semantics of old isatest-makedist;
wenzelm
parents:
64348
diff
changeset
|
461 |
for (task <- tasks if !exclude_task(task.name)) |
64199 | 462 |
yield log_service.fork_task(start_date, task) |
463 |
join(running) |
|
464 |
}) |
|
64193 | 465 |
|
64170 | 466 |
|
66897 | 467 |
/* repository structure */ |
64199 | 468 |
|
65820 | 469 |
val hg = Mercurial.repository(isabelle_repos) |
66895 | 470 |
val hg_graph = hg.graph() |
67048
ec438988b65a
local user_home for improved performance, but only after given changeset for stability of measurement history;
wenzelm
parents:
67008
diff
changeset
|
471 |
|
66895 | 472 |
def history_base_filter(r: Remote_Build): Item => Boolean = |
473 |
{ |
|
474 |
val base_rev = hg.id(r.history_base) |
|
475 |
val nodes = hg_graph.all_succs(List(base_rev)).toSet |
|
476 |
(item: Item) => nodes(item.isabelle_version) |
|
477 |
} |
|
478 |
||
66897 | 479 |
|
480 |
/* main */ |
|
481 |
||
482 |
val main_start_date = Date.now() |
|
483 |
File.write(main_state_file, main_start_date + " " + log_service.hostname) |
|
484 |
||
64193 | 485 |
run(main_start_date, |
65783
d3d5cb2d6866
pick isabelle_version based on build_log database;
wenzelm
parents:
65771
diff
changeset
|
486 |
Logger_Task("isabelle_cronjob", logger => |
64231
dbc8294c75d3
added remote_build_history tasks: parallel on several remote hosts;
wenzelm
parents:
64220
diff
changeset
|
487 |
run_now( |
67751 | 488 |
SEQ(List(init, build_release, build_history_base, |
66898
8b7c4679c05b
parallel remote_builds2 for the sake of "AFP slow" (with theoretical data race on build_log_dirs);
wenzelm
parents:
66897
diff
changeset
|
489 |
PAR(List(remote_builds1, remote_builds2).map(remote_builds => |
8b7c4679c05b
parallel remote_builds2 for the sake of "AFP slow" (with theoretical data race on build_log_dirs);
wenzelm
parents:
66897
diff
changeset
|
490 |
SEQ(List( |
67080 | 491 |
PAR(remote_builds.map(_.filter(_.active)).map(seq => |
66898
8b7c4679c05b
parallel remote_builds2 for the sake of "AFP slow" (with theoretical data race on build_log_dirs);
wenzelm
parents:
66897
diff
changeset
|
492 |
SEQ( |
8b7c4679c05b
parallel remote_builds2 for the sake of "AFP slow" (with theoretical data race on build_log_dirs);
wenzelm
parents:
66897
diff
changeset
|
493 |
for { |
8b7c4679c05b
parallel remote_builds2 for the sake of "AFP slow" (with theoretical data race on build_log_dirs);
wenzelm
parents:
66897
diff
changeset
|
494 |
(r, i) <- (if (seq.length <= 1) seq.map((_, -1)) else seq.zipWithIndex) |
67048
ec438988b65a
local user_home for improved performance, but only after given changeset for stability of measurement history;
wenzelm
parents:
67008
diff
changeset
|
495 |
(rev, afp_rev) <- r.pick(logger.options, hg.id(), history_base_filter(r)) |
67070
85e6c1ff5be3
removed pointless user_home: no measurable impact;
wenzelm
parents:
67049
diff
changeset
|
496 |
} yield remote_build_history(rev, afp_rev, i, r)))), |
67008 | 497 |
Logger_Task("jenkins_logs", _ => |
498 |
Jenkins.download_logs(Jenkins.build_log_jobs, main_dir)), |
|
66898
8b7c4679c05b
parallel remote_builds2 for the sake of "AFP slow" (with theoretical data race on build_log_dirs);
wenzelm
parents:
66897
diff
changeset
|
499 |
Logger_Task("build_log_database", |
8b7c4679c05b
parallel remote_builds2 for the sake of "AFP slow" (with theoretical data race on build_log_dirs);
wenzelm
parents:
66897
diff
changeset
|
500 |
logger => Isabelle_Devel.build_log_database(logger.options, build_log_dirs)), |
8b7c4679c05b
parallel remote_builds2 for the sake of "AFP slow" (with theoretical data race on build_log_dirs);
wenzelm
parents:
66897
diff
changeset
|
501 |
Logger_Task("build_status", |
8b7c4679c05b
parallel remote_builds2 for the sake of "AFP slow" (with theoretical data race on build_log_dirs);
wenzelm
parents:
66897
diff
changeset
|
502 |
logger => Isabelle_Devel.build_status(logger.options))))))))))) |
64153
769791954872
some timing and logging, similar to old isatest.log;
wenzelm
parents:
64148
diff
changeset
|
503 |
|
64171 | 504 |
log_service.shutdown() |
64170 | 505 |
|
64153
769791954872
some timing and logging, similar to old isatest.log;
wenzelm
parents:
64148
diff
changeset
|
506 |
main_state_file.file.delete |
769791954872
some timing and logging, similar to old isatest.log;
wenzelm
parents:
64148
diff
changeset
|
507 |
} |
769791954872
some timing and logging, similar to old isatest.log;
wenzelm
parents:
64148
diff
changeset
|
508 |
|
769791954872
some timing and logging, similar to old isatest.log;
wenzelm
parents:
64148
diff
changeset
|
509 |
|
769791954872
some timing and logging, similar to old isatest.log;
wenzelm
parents:
64148
diff
changeset
|
510 |
|
769791954872
some timing and logging, similar to old isatest.log;
wenzelm
parents:
64148
diff
changeset
|
511 |
/** command line entry point **/ |
769791954872
some timing and logging, similar to old isatest.log;
wenzelm
parents:
64148
diff
changeset
|
512 |
|
64148 | 513 |
def main(args: Array[String]) |
514 |
{ |
|
515 |
Command_Line.tool0 { |
|
516 |
var force = false |
|
517 |
var verbose = false |
|
64187 | 518 |
var exclude_task = Set.empty[String] |
64148 | 519 |
|
520 |
val getopts = Getopts(""" |
|
521 |
Usage: Admin/cronjob/main [OPTIONS] |
|
522 |
||
523 |
Options are: |
|
524 |
-f apply force to do anything |
|
525 |
-v verbose |
|
64187 | 526 |
-x NAME exclude tasks with this name |
64148 | 527 |
""", |
528 |
"f" -> (_ => force = true), |
|
64187 | 529 |
"v" -> (_ => verbose = true), |
530 |
"x:" -> (arg => exclude_task += arg)) |
|
64148 | 531 |
|
532 |
val more_args = getopts(args) |
|
533 |
if (more_args.nonEmpty) getopts.usage() |
|
534 |
||
64909 | 535 |
val progress = if (verbose) new Console_Progress() else No_Progress |
64148 | 536 |
|
64187 | 537 |
if (force) cronjob(progress, exclude_task) |
64153
769791954872
some timing and logging, similar to old isatest.log;
wenzelm
parents:
64148
diff
changeset
|
538 |
else error("Need to apply force to do anything") |
64148 | 539 |
} |
540 |
} |
|
541 |
} |