Skip to content

Commit 7d913b3

Browse files
craig[bot]herkolategan
andcommitted
Merge #143262
143262: microbench-ci: benchmark suite tuning r=DarrylWong a=herkolategan Previously, one node local KV microbenchmarks were run as part of CI. These tests are sensitive to compiler induced variance. Even though the regressions / improvements are reproducible, often the code change is unrelated to the performance change. It happens often enough with these benchmarks that it could be wasteful for engineers to investigate these slight differences. This change updates the benchmark suite to run the 3 node KV benchmarks instead which is less likely to be triggered due to compiler induced variance. Epic: None Release note: None Co-authored-by: Herko Lategan <[email protected]>
2 parents 02adab7 + b4ac112 commit 7d913b3

File tree

6 files changed

+53
-20
lines changed

6 files changed

+53
-20
lines changed

pkg/cmd/microbench-ci/benchmark.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,17 @@ type (
2828
Iterations int `yaml:"iterations"`
2929
CompareAlpha float64 `yaml:"compare_alpha"`
3030
Retries int `yaml:"retries"`
31-
Metrics []string `yaml:"metrics"`
31+
Metrics []Metric `yaml:"metrics"`
3232
}
3333
Benchmarks []Benchmark
3434
ProfileType string
3535
)
3636

37+
type Metric struct {
38+
Name string `yaml:"name"`
39+
Threshold float64 `yaml:"threshold"`
40+
}
41+
3742
const (
3843
ProfileCPU ProfileType = "cpu"
3944
ProfileMemory ProfileType = "memory"

pkg/cmd/microbench-ci/compare.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"bufio"
1010
"bytes"
1111
"fmt"
12+
"math"
1213
"os"
1314
"path"
1415

@@ -66,6 +67,22 @@ func (c *CompareResult) status(metricName string) Status {
6667
} else if cc.Delta*float64(entry.Better) < 0 {
6768
status = Regressed
6869
}
70+
71+
// Check if the metric has a delta cutoff threshold.
72+
threshold := 0.0
73+
for _, metric := range c.Benchmark.Metrics {
74+
if metric.Name == metricName {
75+
threshold = metric.Threshold
76+
break
77+
}
78+
}
79+
// If the threshold is set and the delta is less than the threshold, we
80+
// consider the metric to have no change. This accounts for compiler induced
81+
// variance, where the regression might be reproducible, but the change is
82+
// unrelated to the changes in the code.
83+
if math.Abs(cc.Delta) < threshold {
84+
status = NoChange
85+
}
6986
return status
7087
}
7188

pkg/cmd/microbench-ci/config/pull-request-suite.yml

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,37 @@ benchmarks:
99
compare_alpha: 0.025
1010
retries: 3
1111
metrics:
12-
- "sec/op"
13-
- "allocs/op"
12+
- name: "sec/op"
13+
threshold: .3
14+
- name: "allocs/op"
15+
threshold: .1
1416

1517
- display_name: Sysbench
16-
labels: ["KV", "1node", "local", "oltp_read_only"]
17-
name: "BenchmarkSysbench/KV/1node_local/oltp_read_only"
18+
labels: ["KV", "3node", "oltp_read_only"]
19+
name: "BenchmarkSysbench/KV/3node/oltp_read_only"
1820
package: "pkg/sql/tests"
1921
runner_group: 2
20-
count: 20
21-
iterations: 6000
22+
count: 15
23+
iterations: 3000
2224
compare_alpha: 0.025
2325
retries: 3
2426
metrics:
25-
- "sec/op"
26-
- "allocs/op"
27+
- name: "sec/op"
28+
threshold: .4
29+
- name: "allocs/op"
30+
threshold: .1
2731

2832
- display_name: Sysbench
29-
labels: ["KV", "1node", "local", "oltp_write_only"]
30-
name: "BenchmarkSysbench/KV/1node_local/oltp_write_only"
33+
labels: ["KV", "3node", "oltp_write_only"]
34+
name: "BenchmarkSysbench/KV/3node/oltp_write_only"
3135
package: "pkg/sql/tests"
3236
runner_group: 2
33-
count: 20
34-
iterations: 6000
37+
count: 15
38+
iterations: 3000
3539
compare_alpha: 0.025
3640
retries: 3
3741
metrics:
38-
- "sec/op"
39-
- "allocs/op"
42+
- name: "sec/op"
43+
threshold: .4
44+
- name: "allocs/op"
45+
threshold: .1

pkg/cmd/microbench-ci/report.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ func (c *CompareResult) generateSummaryData(
5959
statusTemplateFunc func(status Status) string,
6060
) []SummaryData {
6161
summaryData := make([]SummaryData, 0, len(c.MetricMap))
62-
for _, metricName := range c.Benchmark.Metrics {
62+
for _, metric := range c.Benchmark.Metrics {
63+
metricName := metric.Name
6364
entry := c.MetricMap[metricName]
6465
if entry == nil {
6566
log.Printf("WARN: no metric found for benchmark metric %q", metricName)

pkg/cmd/microbench-ci/testdata/regression.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ benchmarks:
1111
compare_alpha: 0.05
1212
retries: 3
1313
metrics:
14-
- "sec/op"
15-
- "allocs/op"
14+
- name: "sec/op"
15+
threshold: 0.005
16+
- name: "allocs/op"
17+
threshold: 0.002
1618

1719
----
1820

pkg/cmd/microbench-ci/testdata/summary.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ benchmarks:
1111
compare_alpha: 0.05
1212
retries: 3
1313
metrics:
14-
- "sec/op"
15-
- "allocs/op"
14+
- name: "sec/op"
15+
threshold: 0.001
16+
- name: "allocs/op"
17+
threshold: 0.001
1618

1719
----
1820

0 commit comments

Comments
 (0)