-
Notifications
You must be signed in to change notification settings - Fork 21
/
BlockingQueuePoisonApple_statsSC.tla
63 lines (53 loc) · 2.65 KB
/
BlockingQueuePoisonApple_statsSC.tla
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
--------------------- MODULE BlockingQueuePoisonApple_statsSC ---------------------
EXTENDS TLC, IOUtils, Naturals, Sequences, CSV
\* Assume a recent version of TLC that has support for all shenanigans below.
ASSUME TLCGet("revision").timestamp >= 1628118195
-----------------------------------------------------------------------------
\* Filename for the CSV file that appears also in the R script and is passed
\* to the nested TLC instances that are forked below.
CSVFile ==
"BQPA_B_" \o ToString(JavaTime) \o ".csv"
\* Write column headers to CSV file at startup of TLC instance that "runs"
\* this script and forks the nested instances of TLC that simulate the spec
\* and collect the statistics.
ASSUME
CSVWrite("trace,level,P,C,B,over,under", <<>>, CSVFile)
PlotStatistics ==
\* Have TLC execute the R script on the generated CSV file.
LET proc == IOExec(<<
\* Find R on the current system (known to work on macOS and Linux).
"/usr/bin/env", "Rscript",
"BlockingQueuePoisonApple_stats.R", CSVFile>>)
IN \/ proc.exitValue = 0
\/ PrintT(proc) \* Print stdout and stderr if R script fails.
-----------------------------------------------------------------------------
\* Command to fork nested TLC instances that simulate the spec and collect the
\* statistics. TLCGet("config").install gives the path to the TLC jar also
\* running this script.
Cmd == LET absolutePathOfTLC == TLCGet("config").install
IN <<"java", "-jar",
absolutePathOfTLC,
"-generate", "num=100",
"-config", "BlockingQueuePoisonApple_stats.tla",
"BlockingQueuePoisonApple_stats">>
Success(e) ==
/\ PrintT(e)
/\ PlotStatistics
ASSUME \A conf \in
{ r \in [ {"P","C","B"} -> {1,2,4,8,16,32}]:
\* Check only symmetric configs of Producers and Consumers.
\* Over/Under-provisioning for asymmetrics numbers of
\* Producers and Consumers.
r.P = r.C }:
LET ret == IOEnvExec(conf @@ [W |-> 16, Out |-> CSVFile], Cmd).exitValue
IN CASE ret = 0 -> Success(conf)
[] ret = 10 -> PrintT(<<conf, "Assumption violation">>)
[] ret = 12 -> PrintT(<<conf, "Safety violation">>)
[] ret = 13 -> PrintT(<<conf, "Liveness violation">>)
[] OTHER -> Print(<<conf, IOEnvExec(conf, Cmd), "Error">>, FALSE)
=============================================================================
---- CONFIG BlockingQueuePoisonAppleSC ----
\* TLC always expects a configuration file, but an empty one will do in this case.
\* If this approach proves useful, TLC should be extended to launch without a config
\* file.
====