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