Deployment Controller - don't copy pods in getPodMapForDeployment
As the benchmark shows it speeds up the method~x4 and reduces memory consumption ~x20. ``` benchmark old ns/op new ns/op delta BenchmarkGetPodMapForDeployment-12 276121 72591 -73.71% benchmark old allocs new allocs delta BenchmarkGetPodMapForDeployment-12 241 238 -1.24% benchmark old bytes new bytes delta BenchmarkGetPodMapForDeployment-12 554025 28956 -94.77% ```
This commit is contained in:
@@ -633,7 +633,7 @@ func TestGetPodMapForReplicaSets(t *testing.T) {
|
||||
}
|
||||
podCount := 0
|
||||
for _, podList := range podMap {
|
||||
podCount += len(podList.Items)
|
||||
podCount += len(podList)
|
||||
}
|
||||
if got, want := podCount, 3; got != want {
|
||||
t.Errorf("podCount = %v, want %v", got, want)
|
||||
@@ -642,19 +642,19 @@ func TestGetPodMapForReplicaSets(t *testing.T) {
|
||||
if got, want := len(podMap), 2; got != want {
|
||||
t.Errorf("len(podMap) = %v, want %v", got, want)
|
||||
}
|
||||
if got, want := len(podMap[rs1.UID].Items), 2; got != want {
|
||||
if got, want := len(podMap[rs1.UID]), 2; got != want {
|
||||
t.Errorf("len(podMap[rs1]) = %v, want %v", got, want)
|
||||
}
|
||||
expect := map[string]struct{}{"rs1-pod": {}, "pod4": {}}
|
||||
for _, pod := range podMap[rs1.UID].Items {
|
||||
for _, pod := range podMap[rs1.UID] {
|
||||
if _, ok := expect[pod.Name]; !ok {
|
||||
t.Errorf("unexpected pod name for rs1: %s", pod.Name)
|
||||
}
|
||||
}
|
||||
if got, want := len(podMap[rs2.UID].Items), 1; got != want {
|
||||
if got, want := len(podMap[rs2.UID]), 1; got != want {
|
||||
t.Errorf("len(podMap[rs2]) = %v, want %v", got, want)
|
||||
}
|
||||
if got, want := podMap[rs2.UID].Items[0].Name, "rs2-pod"; got != want {
|
||||
if got, want := podMap[rs2.UID][0].Name, "rs2-pod"; got != want {
|
||||
t.Errorf("podMap[rs2] = [%v], want [%v]", got, want)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user