| ... |
... |
@@ -84,17 +84,12 @@ PerfStat = NamedTuple('PerfStat', [('test_env', TestEnv), |
|
84
|
84
|
('value', float)])
|
|
85
|
85
|
|
|
86
|
86
|
# A test's metric recovered from a commit's git note: the raw sample values
|
|
87
|
|
-# recorded there, and a PerfStat whose value is their mean.
|
|
|
87
|
+# recorded there, and a PerfStat whose value is their mean. Serves as the
|
|
|
88
|
+# baseline when comparing a test run against an earlier commit.
|
|
88
|
89
|
class CommitMetric(NamedTuple):
|
|
89
|
|
- perfStat: PerfStat
|
|
90
|
|
- samples: List[float]
|
|
91
|
|
-
|
|
92
|
|
-# A baseline recovered form stored metrics.
|
|
93
|
|
-class Baseline(NamedTuple):
|
|
94
|
90
|
perfStat: PerfStat
|
|
95
|
91
|
commit: GitHash
|
|
96
|
|
- # The raw samples the baseline value was averaged over.
|
|
97
|
|
- samples: List[float] = []
|
|
|
92
|
+ samples: List[float]
|
|
98
|
93
|
|
|
99
|
94
|
# The type of exceptions which are thrown when computing the current stat value
|
|
100
|
95
|
# fails.
|
| ... |
... |
@@ -486,7 +481,7 @@ _commit_metric_cache: Dict[Tuple[NoteNamespace, GitHash], |
|
486
|
481
|
# instead when looking for ci results)
|
|
487
|
482
|
# metric: str - test metric
|
|
488
|
483
|
# way: str - test way
|
|
489
|
|
-# returns: the Baseline or None if no metric was found within
|
|
|
484
|
+# returns: the baseline CommitMetric or None if no metric was found within
|
|
490
|
485
|
# BaselineSearchDepth commits and since the last expected change
|
|
491
|
486
|
# (ignoring any expected change in the given commit).
|
|
492
|
487
|
def baseline_metric(commit: GitHash,
|
| ... |
... |
@@ -495,7 +490,7 @@ def baseline_metric(commit: GitHash, |
|
495
|
490
|
metric: MetricName,
|
|
496
|
491
|
way: WayName,
|
|
497
|
492
|
baseline_ref: Optional[GitRef]
|
|
498
|
|
- ) -> Optional[Baseline]:
|
|
|
493
|
+ ) -> Optional[CommitMetric]:
|
|
499
|
494
|
# For performance reasons (in order to avoid calling commit_hash), we assert
|
|
500
|
495
|
# commit is already a commit hash.
|
|
501
|
496
|
assert is_commit_hash(commit)
|
| ... |
... |
@@ -511,22 +506,16 @@ def baseline_metric(commit: GitHash, |
|
511
|
506
|
# Searches through previous commits trying local then ci for each commit in.
|
|
512
|
507
|
def find_baseline(namespace: NoteNamespace,
|
|
513
|
508
|
test_env: TestEnv
|
|
514
|
|
- ) -> Optional[Baseline]:
|
|
|
509
|
+ ) -> Optional[CommitMetric]:
|
|
515
|
510
|
if baseline_commit is not None:
|
|
516
|
|
- current_metric = get_commit_metric(namespace, baseline_commit, test_env, name, metric, way)
|
|
517
|
|
- if current_metric is not None:
|
|
518
|
|
- return Baseline(current_metric.perfStat, baseline_commit,
|
|
519
|
|
- current_metric.samples)
|
|
520
|
|
- else:
|
|
521
|
|
- return None
|
|
|
511
|
+ return get_commit_metric(namespace, baseline_commit, test_env, name, metric, way)
|
|
522
|
512
|
|
|
523
|
513
|
for depth, current_commit in list(enumerate(commit_hashes)):
|
|
524
|
514
|
if current_commit == commit: continue
|
|
525
|
515
|
# Check for a metric on this commit.
|
|
526
|
516
|
current_metric = get_commit_metric(namespace, current_commit, test_env, name, metric, way)
|
|
527
|
517
|
if current_metric is not None:
|
|
528
|
|
- return Baseline(current_metric.perfStat, current_commit,
|
|
529
|
|
- current_metric.samples)
|
|
|
518
|
+ return current_metric
|
|
530
|
519
|
|
|
531
|
520
|
# Stop if there is an expected change at this commit. In that case
|
|
532
|
521
|
# metrics on ancestor commits will not be a valid baseline.
|
| ... |
... |
@@ -538,7 +527,7 @@ def baseline_metric(commit: GitHash, |
|
538
|
527
|
# Test environment to use when comparing against CI namespace
|
|
539
|
528
|
ci_test_env = best_fit_ci_test_env()
|
|
540
|
529
|
|
|
541
|
|
- baseline = find_baseline(LocalNamespace, test_env) # type: Optional[Baseline]
|
|
|
530
|
+ baseline = find_baseline(LocalNamespace, test_env) # type: Optional[CommitMetric]
|
|
542
|
531
|
if baseline is None and ci_test_env is not None:
|
|
543
|
532
|
baseline = find_baseline(CiNamespace, ci_test_env)
|
|
544
|
533
|
|
| ... |
... |
@@ -608,6 +597,7 @@ def get_commit_metric(gitNoteRef, |
|
608
|
597
|
currentCacheKey[3],
|
|
609
|
598
|
currentCacheKey[2],
|
|
610
|
599
|
sum(currentValues) / len(currentValues)),
|
|
|
600
|
+ commit,
|
|
611
|
601
|
currentValues)
|
|
612
|
602
|
|
|
613
|
603
|
# Save metrics to the cache.
|
| ... |
... |
@@ -621,7 +611,7 @@ def format_samples(samples: List[float]) -> str: |
|
621
|
611
|
return ', '.join(format_sample(s) for s in samples)
|
|
622
|
612
|
|
|
623
|
613
|
def check_stats_change(actual: PerfStat,
|
|
624
|
|
- baseline: Baseline,
|
|
|
614
|
+ baseline: CommitMetric,
|
|
625
|
615
|
acceptance_window: MetricAcceptanceWindow,
|
|
626
|
616
|
allowed_perf_changes: Dict[TestName, List[AllowedPerfChange]] = {},
|
|
627
|
617
|
force_print = False
|
| ... |
... |
@@ -631,8 +621,8 @@ def check_stats_change(actual: PerfStat, |
|
631
|
621
|
|
|
632
|
622
|
Parameters:
|
|
633
|
623
|
actual: the PerfStat with actual value
|
|
634
|
|
- baseline: the expected Baseline value (this should generally be derived
|
|
635
|
|
- from baseline_metric())
|
|
|
624
|
+ baseline: the CommitMetric to compare against (this should generally be
|
|
|
625
|
+ derived from baseline_metric())
|
|
636
|
626
|
acceptance_window: allowed deviation of the actual value from the expected
|
|
637
|
627
|
value.
|
|
638
|
628
|
allowed_perf_changes: allowed changes in stats. This is a dictionary as
|