mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +00:00
Benchmark for topology spreading filter
Signed-off-by: Aldo Culquicondor <acondor@google.com>
This commit is contained in:
parent
fce286e227
commit
275da7afc0
@ -30,6 +30,7 @@ import (
|
|||||||
"k8s.io/client-go/kubernetes/fake"
|
"k8s.io/client-go/kubernetes/fake"
|
||||||
framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1"
|
framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1"
|
||||||
"k8s.io/kubernetes/pkg/scheduler/internal/cache"
|
"k8s.io/kubernetes/pkg/scheduler/internal/cache"
|
||||||
|
"k8s.io/kubernetes/pkg/scheduler/internal/parallelize"
|
||||||
schedulernodeinfo "k8s.io/kubernetes/pkg/scheduler/nodeinfo"
|
schedulernodeinfo "k8s.io/kubernetes/pkg/scheduler/nodeinfo"
|
||||||
st "k8s.io/kubernetes/pkg/scheduler/testing"
|
st "k8s.io/kubernetes/pkg/scheduler/testing"
|
||||||
)
|
)
|
||||||
@ -1065,7 +1066,7 @@ func TestPreFilterStateRemovePod(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkTestCalPreFilterState(b *testing.B) {
|
func BenchmarkFilter(b *testing.B) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
pod *v1.Pod
|
pod *v1.Pod
|
||||||
@ -1103,17 +1104,30 @@ func BenchmarkTestCalPreFilterState(b *testing.B) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
|
var state *framework.CycleState
|
||||||
b.Run(tt.name, func(b *testing.B) {
|
b.Run(tt.name, func(b *testing.B) {
|
||||||
existingPods, allNodes, _ := st.MakeNodesAndPodsForEvenPodsSpread(tt.pod.Labels, tt.existingPodsNum, tt.allNodesNum, tt.filteredNodesNum)
|
existingPods, allNodes, _ := st.MakeNodesAndPodsForEvenPodsSpread(tt.pod.Labels, tt.existingPodsNum, tt.allNodesNum, tt.filteredNodesNum)
|
||||||
pl := PodTopologySpread{
|
pl := PodTopologySpread{
|
||||||
sharedLister: cache.NewSnapshot(existingPods, allNodes),
|
sharedLister: cache.NewSnapshot(existingPods, allNodes),
|
||||||
}
|
}
|
||||||
|
ctx := context.Background()
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
s := pl.PreFilter(context.Background(), framework.NewCycleState(), tt.pod)
|
state = framework.NewCycleState()
|
||||||
|
s := pl.PreFilter(ctx, state, tt.pod)
|
||||||
if !s.IsSuccess() {
|
if !s.IsSuccess() {
|
||||||
b.Fatal(s.AsError())
|
b.Fatal(s.AsError())
|
||||||
}
|
}
|
||||||
|
filterNode := func(i int) {
|
||||||
|
n, _ := pl.sharedLister.NodeInfos().Get(allNodes[i].Name)
|
||||||
|
pl.Filter(ctx, state, tt.pod, n)
|
||||||
|
}
|
||||||
|
parallelize.Until(ctx, len(allNodes), filterNode)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
b.Run(tt.name+"/Clone", func(b *testing.B) {
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
state.Clone()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user