manirajv06 commented on code in PR #1043:
URL: https://github.com/apache/yunikorn-k8shim/pull/1043#discussion_r3658637383


##########
pkg/cache/context.go:
##########
@@ -706,9 +739,14 @@ func (ctx *Context) IsPodFitNode(name, node string, 
allocate bool) error {
                return ErrorNodeNotFound
        }
        // need to lock cache here as predicates need a stable view into the 
cache
-       ctx.schedulerCache.LockForReads()
-       defer ctx.schedulerCache.UnlockForReads()
-       plugin, err := ctx.predManager.Predicates(pod, targetNode, allocate)
+       ctx.schedulerCache.LockForWrites()
+       defer ctx.schedulerCache.UnlockForWrites()
+       cycleState := ctx.schedulerCache.GetCycleState(pod)
+       if cycleState == nil {
+               return ErrorCycleStateNotFound
+       }
+       plugin, err := ctx.predManager.Filter(pod, targetNode, cycleState, 
allocate)
+       ctx.schedulerCache.DeleteCycleState(pod)

Review Comment:
   Why we do need the cycle state once we decide the node?  Once the node is 
decided, we don't even iterate the next node. Isn't it? There is no need for us 
to run the `Filter()` for next node in the iterator.
   
   BTW, We were clearing the cycle state from cache during the pod removal. But 
now we had changed our mind and decided to delete the cycle state as and when 
we are done with node selection to reduce the memory footprint of the scheduler 
cache. It is as good as keeping the variable in local memory :)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to