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

Adding TLC stats to cimetrics #5807

Merged
merged 26 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
55630a5
experimenting with a stats postcondition
heidihoward Nov 1, 2023
23f10a2
moving stats filename
heidihoward Nov 1, 2023
2bb940a
jsonserialize expects a sequence
heidihoward Nov 1, 2023
0507d0f
undo requestlimit change
heidihoward Nov 1, 2023
6f02257
tidying up json file stats
heidihoward Nov 1, 2023
27e2fbf
Merge branch 'main' into tla-cimetrics
heidihoward Nov 1, 2023
eef132e
tidying up
heidihoward Nov 1, 2023
b514e5a
print statement for stats file
heidihoward Nov 2, 2023
0e1f47f
Merge branch 'main' into tla-cimetrics
heidihoward Nov 2, 2023
2f39151
starting script to upload
heidihoward Nov 2, 2023
f13758d
starting action for upload
heidihoward Nov 2, 2023
5853058
Merge branch 'main' into tla-cimetrics
heidihoward Nov 2, 2023
e4ecc7f
adding test label
heidihoward Nov 2, 2023
c04ed2f
using stats file with consistency spec as well
heidihoward Nov 2, 2023
ce7f5f2
rollback consistency changes
heidihoward Nov 7, 2023
775d5d7
rollback consistency changes
heidihoward Nov 7, 2023
a106bc0
rollback edits to .gitignore before merge with ado migration
heidihoward Nov 7, 2023
ec9ae0b
Merge branch 'main' into tla-cimetrics
heidihoward Nov 7, 2023
b14d78e
trying cimetrics with ado
heidihoward Nov 7, 2023
3365e23
adding test label
heidihoward Nov 7, 2023
e1e3cc4
adding new category for to cimetrics for tlc
heidihoward Nov 7, 2023
8f30c52
giving the new cimetric across to the mongo connection
heidihoward Nov 7, 2023
e1d8297
test run
heidihoward Nov 7, 2023
195f9af
Update .azure-pipelines-templates/model_checking.yml
achamayou Nov 7, 2023
e194afb
Update .azure-pipelines-templates/model_checking.yml
achamayou Nov 7, 2023
715d187
restoring the other mc jobs
heidihoward Nov 7, 2023
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
6 changes: 6 additions & 0 deletions .github/workflows/tlaplus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ jobs:
cd tla/
./tlc.sh -workers auto -config consensus/MCccfraftWithReconfig.cfg consensus/MCccfraft.tla -dumpTrace tla MCccfraftWithReconfig.trace.tla -dumpTrace json MCccfraftWithReconfig.json

- name: Uploading TLC stats to cimetrics
run: |
cd tests
pip3 install -r requirements.txt
python3 upload_tlc_stats.py ../tla/MCccfraftWithReconfig.json

- name: Upload traces in TLA and JSON format
uses: actions/upload-artifact@v3
if: ${{ failure() }}
Expand Down
40 changes: 40 additions & 0 deletions tests/upload_tlc_stats.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the Apache 2.0 License.

import json
import os
import argparse
import cimetrics.upload

from loguru import logger as LOG


def run(filename):
if os.path.exists(filename):
with open(filename) as f:
data = json.load(f)
duration_sec = data["duration"]
dstates = data["distinct"]
LOG.info(
"Uploading metrics - duration: {}, distinct states: {}",
duration_sec,
dstates,
)
with cimetrics.upload.metrics(complete=False) as metrics:
lemmy marked this conversation as resolved.
Show resolved Hide resolved
metrics.put("TLC Duration (s)", duration_sec)
metrics.put("TLC Distinct States", dstates)

else:
LOG.warning(f"Could not find file {filename}: skipping metrics upload")


if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Upload TLC stats to cimetrics.")

parser.add_argument(
"filename",
help="TLC stats JSON file to upload",
)

args = parser.parse_args()
run(args.filename)
3 changes: 2 additions & 1 deletion tla/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ tools/
.DS_Store
*.dot
*TTrace*.tla
*TTrace*.bin
*TTrace*.bin
*_stats.json
5 changes: 5 additions & 0 deletions tla/consensus/MCccfraft.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ CONSTANTS
MaxTermLimit = 1
MaxCommitsNotified = 0
RequestLimit = 3

StatsFilename = "MCccfraft_stats.json"

Timeout <- MCTimeout
Send <- MCSend
Expand Down Expand Up @@ -50,6 +52,9 @@ VIEW View
CHECK_DEADLOCK
FALSE

POSTCONDITION
WriteStatsFile

PROPERTIES
CommittedLogAppendOnlyProp
MonotonicTermProp
Expand Down
13 changes: 12 additions & 1 deletion tla/consensus/MCccfraft.tla
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---------- MODULE MCccfraft ----------
EXTENDS ccfraft, TLC
EXTENDS ccfraft, TLC, Json

CONSTANTS
NodeOne, NodeTwo, NodeThree
Expand All @@ -21,6 +21,11 @@ ASSUME MaxCommitsNotified \in Nat
CONSTANT RequestLimit
ASSUME RequestLimit \in Nat

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


ToServers ==
UNION Range(Configurations)

Expand Down Expand Up @@ -137,4 +142,10 @@ AllReconfigurationsCommitted ==
DebugAllReconfigurationsReachableInv ==
~AllReconfigurationsCommitted

\* Writes TLC stats (such as number of states and duration) to StatsFilename in ndJson format
\* Specify WriteStatsFile as a postcondition to write the stats file at the end of model checking
WriteStatsFile ==
/\ PrintT("Writing stats to file: " \o StatsFilename)
/\ ndJsonSerialize(StatsFilename, <<TLCGet("stats")>>)

===================================
5 changes: 5 additions & 0 deletions tla/consensus/MCccfraftAtomicReconfig.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ CONSTANTS
MaxTermLimit = 4
MaxCommitsNotified = 2
RequestLimit = 3

StatsFilename = "MCccfraftAtomicReconfig_stats.json"

Timeout <- MCTimeout
Send <- MCSend
Expand Down Expand Up @@ -50,6 +52,9 @@ VIEW View
CHECK_DEADLOCK
FALSE

POSTCONDITION
WriteStatsFile

PROPERTIES
CommittedLogAppendOnlyProp
MonotonicTermProp
Expand Down
5 changes: 5 additions & 0 deletions tla/consensus/MCccfraftWithReconfig.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ CONSTANTS
MaxTermLimit = 3
MaxCommitsNotified = 2
RequestLimit = 3

StatsFilename = "MCccfraftWithReconfig_stats.json"

Timeout <- MCTimeout
Send <- MCSend
Expand Down Expand Up @@ -50,6 +52,9 @@ VIEW View
CHECK_DEADLOCK
FALSE

POSTCONDITION
WriteStatsFile

PROPERTIES
CommittedLogAppendOnlyProp
MonotonicTermProp
Expand Down
Loading