From 1b9386aac370ad37ee36e13143ecb8ac8d9e92a2 Mon Sep 17 00:00:00 2001 From: Ania Borowiec Date: Wed, 30 Apr 2025 12:17:33 +0200 Subject: [PATCH] Add comment explaining the metric sampling logic for plugin execution metrics I have just spent some time finding the change that introduced this and reading the discussion in the relevant PR. I assume this comment could save some time for other people new to this code --- pkg/scheduler/schedule_one.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/scheduler/schedule_one.go b/pkg/scheduler/schedule_one.go index 35b78492255..01092f9b503 100644 --- a/pkg/scheduler/schedule_one.go +++ b/pkg/scheduler/schedule_one.go @@ -101,6 +101,9 @@ func (sched *Scheduler) ScheduleOne(ctx context.Context) { // Synchronously attempt to find a fit for the pod. start := time.Now() state := framework.NewCycleState() + // For the sake of performance, scheduler does not measure and export the scheduler_plugin_execution_duration metric + // for every plugin execution in each scheduling cycle. Instead it samples a portion of scheduling cycles - percentage + // determined by pluginMetricsSamplePercent. The line below helps to randomly pick appropriate scheduling cycles. state.SetRecordPluginMetrics(rand.Intn(100) < pluginMetricsSamplePercent) // Initialize an empty podsToActivate struct, which will be filled up by plugins or stay empty.