From b62541fe84182d311703b85d1add295252ba3a8f Mon Sep 17 00:00:00 2001 From: Aldo Culquicondor Date: Wed, 30 Nov 2022 12:53:52 -0500 Subject: [PATCH] Avoid serialization of maps when log level < 10 Change-Id: If264c26ae599602d5b4919301f011c2095d706ee --- .../plugins/noderesources/resource_allocation.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/scheduler/framework/plugins/noderesources/resource_allocation.go b/pkg/scheduler/framework/plugins/noderesources/resource_allocation.go index 6715ccffab2..8e0e072216b 100644 --- a/pkg/scheduler/framework/plugins/noderesources/resource_allocation.go +++ b/pkg/scheduler/framework/plugins/noderesources/resource_allocation.go @@ -67,10 +67,12 @@ func (r *resourceAllocationScorer) score( score := r.scorer(requested, allocatable) - klog.V(10).InfoS("Listing internal info for allocatable resources, requested resources and score", "pod", - klog.KObj(pod), "node", klog.KObj(node), "resourceAllocationScorer", r.Name, - "allocatableResource", allocatable, "requestedResource", requested, "resourceScore", score, - ) + if klogV := klog.V(10); klogV.Enabled() { // Serializing these maps is costly. + klogV.InfoS("Listing internal info for allocatable resources, requested resources and score", "pod", + klog.KObj(pod), "node", klog.KObj(node), "resourceAllocationScorer", r.Name, + "allocatableResource", allocatable, "requestedResource", requested, "resourceScore", score, + ) + } return score, nil }