Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Action and Variable coverage collection #6092

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .azure-pipelines-templates/model_checking.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ jobs:
displayName: MCccfraftWithReconfig.cfg
condition: ne(variables['Build.CronSchedule.DisplayName'], 'Daily build')

- script: ./tlc.sh -workers auto -config consensus/MCccfraftAtomicReconfig.cfg consensus/MCccfraft.tla -dumpTrace tla MCccfraftAtomicReconfig.trace.tla -dumpTrace json MCccfraftAtomicReconfig.json -coverage 1 -nowarning
- script: JVM_OPTIONS=-Dtlc2.TLCGlobals.coverage=3 ./tlc.sh -workers auto -config consensus/MCccfraftAtomicReconfig.cfg consensus/MCccfraft.tla -dumpTrace tla MCccfraftAtomicReconfig.trace.tla -dumpTrace json MCccfraftAtomicReconfig.json -nowarning
workingDirectory: tla
displayName: MCccfraftAtomicReconfig.cfg
condition: eq(variables['Build.CronSchedule.DisplayName'], 'Daily build')

- script: ./tlc.sh -workers auto -config consensus/MCccfraftWithReconfig.cfg consensus/MCccfraft.tla -dumpTrace tla MCccfraftWithReconfig.trace.tla -dumpTrace json MCccfraftWithReconfig.json -coverage 1 -nowarning
- script: JVM_OPTIONS=-Dtlc2.TLCGlobals.coverage=3 ./tlc.sh -workers auto -config consensus/MCccfraftWithReconfig.cfg consensus/MCccfraft.tla -dumpTrace tla MCccfraftWithReconfig.trace.tla -dumpTrace json MCccfraftWithReconfig.json -nowarning
workingDirectory: tla
displayName: MCccfraftWithReconfig.cfg
condition: eq(variables['Build.CronSchedule.DisplayName'], 'Daily build')
Expand All @@ -49,10 +49,10 @@ jobs:
python3 -mvenv env
source env/bin/activate
pip install -r requirements.txt
ls -tr MCccfraftAtomicReconfig_coverage_*.json | xargs cat | python3 actions.py MCccfraftAtomicReconfig.html
rm MCccfraftAtomicReconfig_coverage_*.json
ls -tr MCccfraftWithReconfig_coverage_*.json | xargs cat | python3 actions.py MCccfraftWithReconfig.html
rm MCccfraftWithReconfig_coverage_*.json
ls -tr MCccfraftAtomicReconfig_coverage.json | xargs cat | python3 actions.py MCccfraftAtomicReconfig.html
rm MCccfraftAtomicReconfig_coverage.json
ls -tr MCccfraftWithReconfig_coverage.json | xargs cat | python3 actions.py MCccfraftWithReconfig.html
rm MCccfraftWithReconfig_coverage.json
deactivate
rm -rf env
workingDirectory: tla
Expand Down
14 changes: 8 additions & 6 deletions tla/StatsFile.tla
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---- MODULE StatsFile----
EXTENDS TLC, Json, Sequences, Naturals
EXTENDS TLC, Json, Sequences, Naturals, IOUtils

\* Filename to write TLC stats to
CONSTANT StatsFilename
ASSUME StatsFilename \in STRING

\* Filename to write TLC coverage to
CONSTANT CoverageFilenamePrefix
ASSUME CoverageFilenamePrefix \in STRING
CONSTANT CoverageFilename
ASSUME CoverageFilename \in STRING


\* Writes TLC stats (such as number of states and duration) to StatsFilename in ndJson format
Expand All @@ -16,9 +16,11 @@ WriteStatsFile ==
/\ PrintT("Writing stats to file: " \o StatsFilename)
/\ ndJsonSerialize(StatsFilename, <<TLCGet("stats")>>)

\* Writes TLC coverage to CoverageFilenamePrefix_coverage_*.json in ndJson format
\* Append TLC coverage in ndJson format to file identified by CoverageFilename. Create CoverageFilename if it does not exist.
SerialiseCoverageConstraint ==
LET interval == 500000
IN IF TLCGet("distinct") % interval = 0 THEN ndJsonSerialize(CoverageFilenamePrefix \o "_coverage_" \o ToString(TLCGet("distinct") \div interval) \o ".json", <<TLCGet("spec")>>) ELSE TRUE
IN IF TLCGet("distinct") % interval = 0
THEN Serialize(<<TLCGet("spec")>>, CoverageFilename, [format |-> "NDJSON", charset |-> "UTF-8", openOptions |-> <<"WRITE", "CREATE", "APPEND">>])
ELSE TRUE

====
====
6 changes: 4 additions & 2 deletions tla/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@
"""
A little script to plot TLC action count

Run TLC with -coverage 1 (or higher), and pip the input in, e.g.:
Run TLC with -Dtlc2.TLCGlobals.coverage=3, and pip the input in, e.g.:
ls -tr <spec>_coverage_*.json | xargs cat | python3 actions.py

The spec needs to have constraint like:

SerialiseCoverageConstraint ==
LET interval == 100000
IN IF TLCGet("distinct") % interval = 0 THEN ndJsonSerialize("MCccfraftAtomicReconfig_coverage_" \o ToString(TLCGet("distinct") \div interval) \o ".json", <<TLCGet("spec")>>) ELSE TRUE
IN IF TLCGet("distinct") % interval = 0
THEN Serialize(<<TLCGet("spec")>>, CoverageFilename, [format |-> "NDJSON", charset |-> "UTF-8", openOptions |-> <<"WRITE", "CREATE", "APPEND">>])
ELSE TRUE
"""

TOP=5
Expand Down
2 changes: 1 addition & 1 deletion tla/consensus/MCccfraft.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ CONSTANTS
RequestLimit = 3

StatsFilename = "MCccfraft_stats.json"
CoverageFilenamePrefix = "MCccfraft"
CoverageFilename = "MCccfraft_coverage.json"

Timeout <- MCTimeout
Send <- MCSend
Expand Down
2 changes: 1 addition & 1 deletion tla/consensus/MCccfraftAtomicReconfig.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ CONSTANTS
RequestLimit = 1

StatsFilename = "MCccfraftAtomicReconfig_stats.json"
CoverageFilenamePrefix = "MCccfraftAtomicReconfig"
CoverageFilename = "MCccfraftAtomicReconfig_coverage.json"

Timeout <- MCTimeout
Send <- MCSend
Expand Down
2 changes: 1 addition & 1 deletion tla/consensus/MCccfraftWithReconfig.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ CONSTANTS
RequestLimit = 1

StatsFilename = "MCccfraftWithReconfig_stats.json"
CoverageFilenamePrefix = "MCccfraftWithReconfig"
CoverageFilename = "MCccfraftWithReconfig_coverage.json"

Timeout <- MCTimeout
Send <- MCSend
Expand Down
2 changes: 1 addition & 1 deletion tla/consensus/SIMccfraft.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ CONSTANTS
NodeFive = n5

StatsFilename = "SIMccfraft_stats.json"
CoverageFilenamePrefix = "SIMccraft"
CoverageFilename = "SIMccraft_coverage.json"

Timeout <- SIMTimeout
ChangeConfigurationInt <-SIMChangeConfigurationInt
Expand Down