mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-11 14:11:14 +00:00
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.
This commit is contained in:
@@ -31,22 +31,25 @@ import (
|
|||||||
// BenchmarkScheduling benchmarks the scheduling rate when the cluster has
|
// BenchmarkScheduling benchmarks the scheduling rate when the cluster has
|
||||||
// various quantities of nodes and scheduled pods.
|
// various quantities of nodes and scheduled pods.
|
||||||
func BenchmarkScheduling(b *testing.B) {
|
func BenchmarkScheduling(b *testing.B) {
|
||||||
tests := []struct{ nodes, pods int }{
|
tests := []struct{ nodes, pods, minOps int }{
|
||||||
{nodes: 100, pods: 0},
|
{nodes: 100, pods: 0, minOps: 100},
|
||||||
{nodes: 100, pods: 1000},
|
{nodes: 100, pods: 1000, minOps: 100},
|
||||||
{nodes: 1000, pods: 0},
|
{nodes: 1000, pods: 0, minOps: 100},
|
||||||
{nodes: 1000, pods: 1000},
|
{nodes: 1000, pods: 1000, minOps: 100},
|
||||||
}
|
}
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
name := fmt.Sprintf("%vNodes/%vPods", test.nodes, test.pods)
|
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
|
// benchmarkScheduling benchmarks scheduling rate with specific number of nodes
|
||||||
// and specific number of pods already scheduled. Since an operation takes relatively
|
// and specific number of pods already scheduled.
|
||||||
// long time, b.N should be small: 10 - 100.
|
// Since an operation typically takes more than 1 second, we put a minimum bound on b.N of minOps.
|
||||||
func benchmarkScheduling(numNodes, numScheduledPods int, b *testing.B) {
|
func benchmarkScheduling(numNodes, numScheduledPods, minOps int, b *testing.B) {
|
||||||
|
if b.N < minOps {
|
||||||
|
b.N = minOps
|
||||||
|
}
|
||||||
schedulerConfigFactory, finalFunc := mustSetupScheduler()
|
schedulerConfigFactory, finalFunc := mustSetupScheduler()
|
||||||
defer finalFunc()
|
defer finalFunc()
|
||||||
c := schedulerConfigFactory.GetClient()
|
c := schedulerConfigFactory.GetClient()
|
||||||
|
Reference in New Issue
Block a user