Merge pull request #114216 from alculquicondor/avoid-serialization

Avoid serialization of maps when log level < 10
This commit is contained in:
Kubernetes Prow Robot 2022-12-10 07:54:24 -08:00 committed by GitHub
commit a800f1e0c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 8 deletions

View File

@ -67,10 +67,12 @@ func (r *resourceAllocationScorer) score(
score := r.scorer(requested, allocatable) score := r.scorer(requested, allocatable)
klog.V(10).InfoS("Listing internal info for allocatable resources, requested resources and score", "pod", 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, klog.KObj(pod), "node", klog.KObj(node), "resourceAllocationScorer", r.Name,
"allocatableResource", allocatable, "requestedResource", requested, "resourceScore", score, "allocatableResource", allocatable, "requestedResource", requested, "resourceScore", score,
) )
}
return score, nil return score, nil
} }

View File

@ -145,8 +145,9 @@ func (sched *Scheduler) schedulingCycle(
if status.Code() == framework.Error { if status.Code() == framework.Error {
klog.ErrorS(nil, "Status after running PostFilter plugins for pod", "pod", klog.KObj(pod), "status", status) klog.ErrorS(nil, "Status after running PostFilter plugins for pod", "pod", klog.KObj(pod), "status", status)
} else { } else {
fitError.Diagnosis.PostFilterMsg = status.Message() msg := status.Message()
klog.V(5).InfoS("Status after running PostFilter plugins for pod", "pod", klog.KObj(pod), "status", status) fitError.Diagnosis.PostFilterMsg = msg
klog.V(5).InfoS("Status after running PostFilter plugins for pod", "pod", klog.KObj(pod), "status", msg)
} }
if result != nil { if result != nil {
nominatingInfo = result.NominatingInfo nominatingInfo = result.NominatingInfo
@ -406,8 +407,9 @@ func (sched *Scheduler) findNodesThatFitPod(ctx context.Context, fwk framework.F
return nil, diagnosis, s.AsError() return nil, diagnosis, s.AsError()
} }
// Record the messages from PreFilter in Diagnosis.PreFilterMsg. // Record the messages from PreFilter in Diagnosis.PreFilterMsg.
diagnosis.PreFilterMsg = s.Message() msg := s.Message()
klog.V(5).InfoS("Status after running PreFilter plugins for pod", "pod", klog.KObj(pod), "status", s) diagnosis.PreFilterMsg = msg
klog.V(5).InfoS("Status after running PreFilter plugins for pod", "pod", klog.KObj(pod), "status", msg)
// Status satisfying IsUnschedulable() gets injected into diagnosis.UnschedulablePlugins. // Status satisfying IsUnschedulable() gets injected into diagnosis.UnschedulablePlugins.
if s.FailedPlugin() != "" { if s.FailedPlugin() != "" {
diagnosis.UnschedulablePlugins.Insert(s.FailedPlugin()) diagnosis.UnschedulablePlugins.Insert(s.FailedPlugin())