From 3a456bf9cbf15a80a47d2619c8a494388d848098 Mon Sep 17 00:00:00 2001 From: Jonathan Basseri Date: Mon, 18 Dec 2017 11:19:15 -0800 Subject: [PATCH] Set a minimum b.N for scheduler_perf benchmarks. Under the default behavior of Go benchmark tests, all our scheduler_perf benchmark tests run with b.N=1, which is lower than we would like. This adds a lower bound to b.N so that the results are more meaningful. The alternative to this change is to always run these tests with the -benchtime flag set to a duration which will force b.N to increase. That would cause any test setup to be executed repeatedly as b.N ramps up, and -timout would probably also need to be set higher. --- .../scheduler_perf/scheduler_bench_test.go | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/test/integration/scheduler_perf/scheduler_bench_test.go b/test/integration/scheduler_perf/scheduler_bench_test.go index ee2ca2fbf1b..608e4888b51 100644 --- a/test/integration/scheduler_perf/scheduler_bench_test.go +++ b/test/integration/scheduler_perf/scheduler_bench_test.go @@ -31,22 +31,25 @@ import ( // BenchmarkScheduling benchmarks the scheduling rate when the cluster has // various quantities of nodes and scheduled pods. func BenchmarkScheduling(b *testing.B) { - tests := []struct{ nodes, pods int }{ - {nodes: 100, pods: 0}, - {nodes: 100, pods: 1000}, - {nodes: 1000, pods: 0}, - {nodes: 1000, pods: 1000}, + tests := []struct{ nodes, pods, minOps int }{ + {nodes: 100, pods: 0, minOps: 100}, + {nodes: 100, pods: 1000, minOps: 100}, + {nodes: 1000, pods: 0, minOps: 100}, + {nodes: 1000, pods: 1000, minOps: 100}, } for _, test := range tests { name := fmt.Sprintf("%vNodes/%vPods", test.nodes, test.pods) - b.Run(name, func(b *testing.B) { benchmarkScheduling(test.nodes, test.pods, b) }) + b.Run(name, func(b *testing.B) { benchmarkScheduling(test.nodes, test.pods, test.minOps, b) }) } } // benchmarkScheduling benchmarks scheduling rate with specific number of nodes -// and specific number of pods already scheduled. Since an operation takes relatively -// long time, b.N should be small: 10 - 100. -func benchmarkScheduling(numNodes, numScheduledPods int, b *testing.B) { +// and specific number of pods already scheduled. +// Since an operation typically takes more than 1 second, we put a minimum bound on b.N of minOps. +func benchmarkScheduling(numNodes, numScheduledPods, minOps int, b *testing.B) { + if b.N < minOps { + b.N = minOps + } schedulerConfigFactory, finalFunc := mustSetupScheduler() defer finalFunc() c := schedulerConfigFactory.GetClient()