From 7b3638ea773dafe1c1eb2723d21a8a5c553bd747 Mon Sep 17 00:00:00 2001 From: Jonathan Basseri Date: Tue, 19 Dec 2017 16:32:34 -0800 Subject: [PATCH] Avoid string concatenation when comparing pods. Pod comparison in (*NodeInfo).Filter was using GetPodFullName before comparing pod names. This is a concatenation of pod name and pod namespace, and it is significantly faster to compare name & namespace instead. --- plugin/pkg/scheduler/schedulercache/node_info.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugin/pkg/scheduler/schedulercache/node_info.go b/plugin/pkg/scheduler/schedulercache/node_info.go index 13f71d525a..99fb77430c 100644 --- a/plugin/pkg/scheduler/schedulercache/node_info.go +++ b/plugin/pkg/scheduler/schedulercache/node_info.go @@ -510,12 +510,11 @@ func getPodKey(pod *v1.Pod) (string, error) { // matches NodeInfo.node and the pod is not found in the pods list. Otherwise, // returns true. func (n *NodeInfo) Filter(pod *v1.Pod) bool { - pFullName := util.GetPodFullName(pod) if pod.Spec.NodeName != n.node.Name { return true } for _, p := range n.pods { - if util.GetPodFullName(p) == pFullName { + if p.Name == pod.Name && p.Namespace == pod.Namespace { return true } }