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 24 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
23 changes: 17 additions & 6 deletions .azure-pipelines-templates/model_checking.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,24 @@ jobs:
workingDirectory: tla
displayName: MCccfraft.cfg

- script: ./tlc.sh -workers auto -config consensus/MCccfraftAtomicReconfig.cfg consensus/MCccfraft.tla -dumpTrace tla MCccfraftAtomicReconfig.trace.tla -dumpTrace json MCccfraftAtomicReconfig.json
workingDirectory: tla
displayName: MCccfraftAtomicReconfig.cfg
# - script: ./tlc.sh -workers auto -config consensus/MCccfraftAtomicReconfig.cfg consensus/MCccfraft.tla -dumpTrace tla MCccfraftAtomicReconfig.trace.tla -dumpTrace json MCccfraftAtomicReconfig.json
# workingDirectory: tla
# displayName: MCccfraftAtomicReconfig.cfg

- script: ./tlc.sh -workers auto -config consensus/MCccfraftWithReconfig.cfg consensus/MCccfraft.tla -dumpTrace tla MCccfraftWithReconfig.trace.tla -dumpTrace json MCccfraftWithReconfig.json
workingDirectory: tla
displayName: MCccfraftWithReconfig.cfg
# - script: ./tlc.sh -workers auto -config consensus/MCccfraftWithReconfig.cfg consensus/MCccfraft.tla -dumpTrace tla MCccfraftWithReconfig.trace.tla -dumpTrace json MCccfraftWithReconfig.json
# workingDirectory: tla
# displayName: MCccfraftWithReconfig.cfg

- script: |
set -ex
python3.8 -m venv env
source env/bin/activate
python -m pip install -r requirements.txt
python3 upload_tlc_stats.py 3node_fixed ../tla/MCccfraft.json
achamayou marked this conversation as resolved.
Show resolved Hide resolved
env:
METRICS_MONGO_CONNECTION: $(METRICS_MONGO_CONNECTION)
workingDirectory: tests
displayName: Uploading TLC stats to cimetrics

- task: PublishPipelineArtifact@1
inputs:
Expand Down
1 change: 1 addition & 0 deletions metrics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ monitoring_span: 150
groups:
"SGX": ".*_sgx_.*"
"Virtual": ".*_virtual_.*"
"TLC": "tlc_.*"
"Others": ".*"
46 changes: 46 additions & 0 deletions tests/upload_tlc_stats.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# 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(test_label, 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 for {} - duration: {}, distinct states: {}",
test_label,
duration_sec,
dstates,
)
with cimetrics.upload.metrics(complete=False) as metrics:
lemmy marked this conversation as resolved.
Show resolved Hide resolved
metrics.put(f"tlc_{test_label}_duration_s", duration_sec)
metrics.put(f"tlc_{test_label}_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(
"test_label",
help="test name to upload metrics under",
)

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

args = parser.parse_args()
run(args.test_label, args.filename)
3 changes: 2 additions & 1 deletion tla/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ tools/
*.dot
*TTrace*.tla
*TTrace*.bin
**/states.dump*
*_stats.json
**/states.dump*
14 changes: 14 additions & 0 deletions tla/StatsFile.tla
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---- MODULE StatsFile----
EXTENDS TLC, Json, Sequences

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

\* 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/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
5 changes: 4 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, StatsFile

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


ToServers ==
UNION Range(Configurations)

Expand Down Expand Up @@ -137,4 +138,6 @@ AllReconfigurationsCommitted ==
DebugAllReconfigurationsReachableInv ==
~AllReconfigurationsCommitted



===================================
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
7 changes: 6 additions & 1 deletion tla/consensus/MCccfraftWithReconfig.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ CONSTANTS

MaxTermLimit = 3
MaxCommitsNotified = 2
RequestLimit = 3
RequestLimit = 2

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