From 77e5883acff25a64b07487e96846959c83df37a4 Mon Sep 17 00:00:00 2001 From: Sai Sindhur Malleni Date: Tue, 10 Feb 2026 11:54:11 -0500 Subject: [PATCH] [Perf] Update labelGPUNodes() to reset updateLabels inside loop As a golden rule of performance, we should never do work that is not necessary. In the current implementation where updateLabels is declared outside the for loop, if updateLabels becomes true for the first node in a large GPU cluster, it triggers a PATCH request to the API for every subsequent node even when not necessary. This maybe a cheap call but we should never do work that is not necessary. Moving updateLabels inside of the for loop, reduces APi calls and load, along with improving reconcilliation time. Signed-off-by: Sai Sindhur Malleni --- controllers/state_manager.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/controllers/state_manager.go b/controllers/state_manager.go index 4567a7c8c..0f10e40e8 100644 --- a/controllers/state_manager.go +++ b/controllers/state_manager.go @@ -488,11 +488,10 @@ func (n *ClusterPolicyController) labelGPUNodes() (bool, int, error) { } clusterHasNFDLabels := false - updateLabels := false gpuNodesTotal := 0 for _, node := range list.Items { node := node - + updateLabels := false nodeOriginal := node.DeepCopy() // get node labels labels := node.GetLabels()