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