You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@yunikorn.apache.org by "Peter Bacsko (Jira)" <ji...@apache.org> on 2023/05/17 18:04:00 UTC

[jira] [Comment Edited] (YUNIKORN-1747) Improve the performance of nodeInfoListerImpl.HavePodsWithAffinityList()

    [ https://issues.apache.org/jira/browse/YUNIKORN-1747?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17723558#comment-17723558 ] 

Peter Bacsko edited comment on YUNIKORN-1747 at 5/17/23 6:03 PM:
-----------------------------------------------------------------

alloc_space sample from one of our upstream user:

!image-2023-05-17-20-02-57-177.png!


was (Author: pbacsko):
alloc_space sample from our upstream user:

!image-2023-05-17-20-02-57-177.png!

> 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
>            Assignee: Peter Bacsko
>            Priority: Major
>         Attachments: image-2023-05-17-20-02-57-177.png
>
>
> 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 "result" slice, save it and update the per-node generation data



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

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@yunikorn.apache.org
For additional commands, e-mail: issues-help@yunikorn.apache.org