Commit f3f6ffaa authored by k8s-merge-robot's avatar k8s-merge-robot

Merge pull request #24524 from wojtek-t/fix_scheduler_2

Automatic merge from submit-queue Add RC and container pors to scheduler benchmark Fix #23263 Ref #24408 However - scheduler throughput is still ~140 initially, whereas in reality we have 35-40. There are still significant difference we should understand. @hongchaodeng @xiang90
parents b274911e a4b3f473
...@@ -42,7 +42,6 @@ func NewNodeAffinityPriority(nodeLister algorithm.NodeLister) algorithm.Priority ...@@ -42,7 +42,6 @@ func NewNodeAffinityPriority(nodeLister algorithm.NodeLister) algorithm.Priority
// the node satisfies and the more the preferredSchedulingTerm that is satisfied weights, the higher // the node satisfies and the more the preferredSchedulingTerm that is satisfied weights, the higher
// score the node gets. // score the node gets.
func (s *NodeAffinity) CalculateNodeAffinityPriority(pod *api.Pod, nodeNameToInfo map[string]*schedulercache.NodeInfo, nodeLister algorithm.NodeLister) (schedulerapi.HostPriorityList, error) { func (s *NodeAffinity) CalculateNodeAffinityPriority(pod *api.Pod, nodeNameToInfo map[string]*schedulercache.NodeInfo, nodeLister algorithm.NodeLister) (schedulerapi.HostPriorityList, error) {
var maxCount int var maxCount int
counts := map[string]int{} counts := map[string]int{}
......
...@@ -54,7 +54,7 @@ func benchmarkScheduling(numNodes, numScheduledPods int, b *testing.B) { ...@@ -54,7 +54,7 @@ func benchmarkScheduling(numNodes, numScheduledPods int, b *testing.B) {
c := schedulerConfigFactory.Client c := schedulerConfigFactory.Client
makeNodes(c, numNodes) makeNodes(c, numNodes)
makePods(c, numScheduledPods) makePodsFromRC(c, "rc1", numScheduledPods)
for { for {
scheduled := schedulerConfigFactory.ScheduledPodLister.Store.List() scheduled := schedulerConfigFactory.ScheduledPodLister.Store.List()
if len(scheduled) >= numScheduledPods { if len(scheduled) >= numScheduledPods {
...@@ -64,7 +64,7 @@ func benchmarkScheduling(numNodes, numScheduledPods int, b *testing.B) { ...@@ -64,7 +64,7 @@ func benchmarkScheduling(numNodes, numScheduledPods int, b *testing.B) {
} }
// start benchmark // start benchmark
b.ResetTimer() b.ResetTimer()
makePods(c, b.N) makePodsFromRC(c, "rc2", b.N)
for { for {
// This can potentially affect performance of scheduler, since List() is done under mutex. // This can potentially affect performance of scheduler, since List() is done under mutex.
// TODO: Setup watch on apiserver and wait until all pods scheduled. // TODO: Setup watch on apiserver and wait until all pods scheduled.
......
...@@ -42,7 +42,7 @@ func schedulePods(numNodes, numPods int) { ...@@ -42,7 +42,7 @@ func schedulePods(numNodes, numPods int) {
c := schedulerConfigFactory.Client c := schedulerConfigFactory.Client
makeNodes(c, numNodes) makeNodes(c, numNodes)
makePods(c, numPods) makePodsFromRC(c, "rc1", numPods)
prev := 0 prev := 0
start := time.Now() start := time.Now()
......
...@@ -42,8 +42,8 @@ kube::log::status "performance test start" ...@@ -42,8 +42,8 @@ kube::log::status "performance test start"
if ${RUN_BENCHMARK:-false}; then if ${RUN_BENCHMARK:-false}; then
go test -c -o "perf.test" go test -c -o "perf.test"
"./perf.test" -test.bench=. -test.run=xxxx -test.cpuprofile=prof.out "./perf.test" -test.bench=. -test.run=xxxx -test.cpuprofile=prof.out
kube::log::status "benchmark tests finished"
fi fi
kube::log::status "benchmark tests finished"
# Running density tests. It might take a long time. # Running density tests. It might take a long time.
go test -test.run=. -test.timeout=60m go test -test.run=. -test.timeout=60m
kube::log::status "density tests finished" kube::log::status "density tests finished"
...@@ -28,6 +28,7 @@ import ( ...@@ -28,6 +28,7 @@ import (
"k8s.io/kubernetes/pkg/client/restclient" "k8s.io/kubernetes/pkg/client/restclient"
client "k8s.io/kubernetes/pkg/client/unversioned" client "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/master" "k8s.io/kubernetes/pkg/master"
"k8s.io/kubernetes/pkg/util/workqueue"
"k8s.io/kubernetes/plugin/pkg/scheduler" "k8s.io/kubernetes/plugin/pkg/scheduler"
_ "k8s.io/kubernetes/plugin/pkg/scheduler/algorithmprovider" _ "k8s.io/kubernetes/plugin/pkg/scheduler/algorithmprovider"
"k8s.io/kubernetes/plugin/pkg/scheduler/factory" "k8s.io/kubernetes/plugin/pkg/scheduler/factory"
...@@ -92,7 +93,7 @@ func makeNodes(c client.Interface, nodeCount int) { ...@@ -92,7 +93,7 @@ func makeNodes(c client.Interface, nodeCount int) {
}, },
Status: api.NodeStatus{ Status: api.NodeStatus{
Capacity: api.ResourceList{ Capacity: api.ResourceList{
api.ResourcePods: *resource.NewQuantity(32, resource.DecimalSI), api.ResourcePods: *resource.NewQuantity(110, resource.DecimalSI),
api.ResourceCPU: resource.MustParse("4"), api.ResourceCPU: resource.MustParse("4"),
api.ResourceMemory: resource.MustParse("32Gi"), api.ResourceMemory: resource.MustParse("32Gi"),
}, },
...@@ -109,54 +110,61 @@ func makeNodes(c client.Interface, nodeCount int) { ...@@ -109,54 +110,61 @@ func makeNodes(c client.Interface, nodeCount int) {
} }
} }
// makePods will setup specified number of scheduled pods. func makePodSpec() api.PodSpec {
// Currently it goes through scheduling path and it's very slow to setup large number of pods. return api.PodSpec{
// TODO: Setup pods evenly on all nodes and quickly/non-linearly. Containers: []api.Container{{
func makePods(c client.Interface, podCount int) { Name: "pause",
glog.Infof("making %d pods", podCount) Image: "gcr.io/google_containers/pause:1.0",
basePod := &api.Pod{ Ports: []api.ContainerPort{{ContainerPort: 80}},
Resources: api.ResourceRequirements{
Limits: api.ResourceList{
api.ResourceCPU: resource.MustParse("100m"),
api.ResourceMemory: resource.MustParse("500Mi"),
},
Requests: api.ResourceList{
api.ResourceCPU: resource.MustParse("100m"),
api.ResourceMemory: resource.MustParse("500Mi"),
},
},
}},
}
}
// makePodsFromRC will create a ReplicationController object and
// a given number of pods (imitating the controller).
func makePodsFromRC(c client.Interface, name string, podCount int) {
rc := &api.ReplicationController{
ObjectMeta: api.ObjectMeta{ ObjectMeta: api.ObjectMeta{
GenerateName: "scheduler-test-pod-", Name: name,
}, },
Spec: api.PodSpec{ Spec: api.ReplicationControllerSpec{
Containers: []api.Container{{ Replicas: podCount,
Name: "pause", Selector: map[string]string{"name": name},
Image: "gcr.io/google_containers/pause:1.0", Template: &api.PodTemplateSpec{
Resources: api.ResourceRequirements{ ObjectMeta: api.ObjectMeta{
Limits: api.ResourceList{ Labels: map[string]string{"name": name},
api.ResourceCPU: resource.MustParse("100m"),
api.ResourceMemory: resource.MustParse("500Mi"),
},
Requests: api.ResourceList{
api.ResourceCPU: resource.MustParse("100m"),
api.ResourceMemory: resource.MustParse("500Mi"),
},
}, },
}}, Spec: makePodSpec(),
},
}, },
} }
threads := 30 if _, err := c.ReplicationControllers("default").Create(rc); err != nil {
remaining := make(chan int, 1000) glog.Fatalf("unexpected error: %v", err)
go func() { }
for i := 0; i < podCount; i++ {
remaining <- i basePod := &api.Pod{
} ObjectMeta: api.ObjectMeta{
close(remaining) GenerateName: "scheduler-test-pod-",
}() Labels: map[string]string{"name": name},
for i := 0; i < threads; i++ { },
go func() { Spec: makePodSpec(),
for { }
_, ok := <-remaining createPod := func(i int) {
if !ok { for {
return if _, err := c.Pods("default").Create(basePod); err == nil {
} break
for {
_, err := c.Pods("default").Create(basePod)
if err == nil {
break
}
}
} }
}() }
} }
workqueue.Parallelize(30, podCount, createPod)
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment