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

Update performance baseline checks #4520

Merged
merged 4 commits into from
Dec 6, 2023
Merged
Changes from 1 commit
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
29 changes: 13 additions & 16 deletions CIME/baselines/performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,8 @@ def write_baseline_file(baseline_file, value):

timestamp = get_timestamp(timestamp_format="%Y-%m-%d_%H:%M:%S")

with open(baseline_file, "w") as fd:
fd.write(f"# sha:{commit_hash} date: {timestamp}\n")
fd.write(value)
with open(baseline_file, "a") as fd:
fd.write(f"sha:{commit_hash} date:{timestamp} {value}\n")


def _perf_get_memory(case, cpllog=None):
Expand Down Expand Up @@ -429,7 +428,7 @@ def read_baseline_file(baseline_file):
Value stored in baseline file without comments.
"""
with open(baseline_file) as fd:
lines = [x.strip() for x in fd.readlines() if not x.startswith("#")]
lines = [x.strip().split(" ")[-1] for x in fd.readlines() if not x.startswith("#")]

return "\n".join(lines)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be return lines[-1] to return the latest value.


Expand Down Expand Up @@ -474,14 +473,13 @@ def _perf_compare_throughput_baseline(case, baseline, tolerance):
if diff is not None:
below_tolerance = diff < tolerance

info = "Throughput changed by {:.2f}%: baseline={:.3f} sypd, tolerance={:d}%, current={:.3f} sypd".format(
diff * 100, baseline, int(tolerance * 100), current
)
if below_tolerance:
comment = "TPUTCOMP: Computation time changed by {:.2f}% relative to baseline".format(
diff * 100
)
comment = "TPUTCOMP: " + info
else:
comment = "Error: TPUTCOMP: Computation time increase > {:d}% from baseline".format(
int(tolerance * 100)
)
comment = "Error: TPUTCOMP: " + info

return below_tolerance, comment

Expand Down Expand Up @@ -533,13 +531,12 @@ def _perf_compare_memory_baseline(case, baseline, tolerance):
if diff is not None:
below_tolerance = diff < tolerance

info = "Memory usage highwater changed by {:.2f}%: baseline={:.3f} sypd, tolerance={:d}%, current={:.3f} sypd".format(
diff * 100, baseline, int(tolerance * 100), current
)
if below_tolerance:
comment = "MEMCOMP: Memory usage highwater has changed by {:.2f}% relative to baseline".format(
diff * 100
)
comment = "MEMCOMP: " + info
else:
comment = "Error: Memory usage increase >{:d}% from baseline's {:f} to {:f}".format(
int(tolerance * 100), baseline, current
)
comment = "Error: MEMCOMP: " + info

return below_tolerance, comment
Loading