Peter Bacsko created YUNIKORN-1747:
--------------------------------------

             Summary: Improve the performance of 
nodeInfoListerImpl.HavePodsWithAffinityList()
                 Key: YUNIKORN-1747
                 URL: https://issues.apache.org/jira/browse/YUNIKORN-1747
             Project: Apache YuniKorn
          Issue Type: Sub-task
          Components: shim - kubernetes
            Reporter: Peter Bacsko


Similarly to YUNIKORN-1746, the method 
{{nodeInfoListerImpl.HavePodsWithAffinityList()}} is called very often, for 
every pod.
{noformat}
func (n nodeInfoListerImpl) HavePodsWithAffinityList() ([]*framework.NodeInfo, 
error) {
        nodes := n.cache.GetNodesInfoMap()
        result := make([]*framework.NodeInfo, 0, len(nodes))
        for _, node := range nodes {
                if len(node.PodsWithAffinity) > 0 {
                        result = append(result, node)
                }
        }
        return result, nil
}
{noformat}
This is more tricky though, but still doable. We need to know whether we should 
include a node to our "result" slice or not. If a node info changes, a counter 
value changes with it. It is maintained inside {{{}framework.NodeInfo{}}}:
{noformat}
// NodeInfo is node level aggregated information.
type NodeInfo struct {
        // Overall node information.
        node *v1.Node

        // Pods running on the node.
        Pods []*PodInfo
        ...
        // Whenever NodeInfo changes, generation is bumped.
        // This is used to avoid cloning it if the object didn't change.
        Generation int64
{noformat}
The algorithm can go as follows:
 * First, we build a slice and save it
 * Save the per-node generation value to a map
 * Upon subsequent calls, we retrieve {{n.cache.GetNodesInfoMap()}}
 * We check if the latest {{node.Generation}} is different from our saved value
 * If it is, just rebuild the entire slice and update the per-node generation 
data



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to