Avoid serialization of maps when log level < 10

Change-Id: If264c26ae599602d5b4919301f011c2095d706ee
This commit is contained in:
Aldo Culquicondor 2022-11-30 12:53:52 -05:00
parent 6c65bed7ce
commit b62541fe84
No known key found for this signature in database
GPG Key ID: 51D903912270D4EE

View File

@ -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
}