From 63e9be02b7783e883f1f61a5ca33ffe612587bac Mon Sep 17 00:00:00 2001 From: Nir Rozenbaum Date: Thu, 4 Sep 2025 08:27:51 +0300 Subject: [PATCH 1/2] removed fmt.Sprintf from scheduler plugins Signed-off-by: Nir Rozenbaum --- pkg/epp/scheduling/framework/plugins/multi/prefix/plugin.go | 3 +-- .../scheduling/framework/plugins/picker/max_score_picker.go | 4 ++-- pkg/epp/scheduling/framework/plugins/picker/random_picker.go | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/pkg/epp/scheduling/framework/plugins/multi/prefix/plugin.go b/pkg/epp/scheduling/framework/plugins/multi/prefix/plugin.go index 7c6993ddb..a0f05c804 100644 --- a/pkg/epp/scheduling/framework/plugins/multi/prefix/plugin.go +++ b/pkg/epp/scheduling/framework/plugins/multi/prefix/plugin.go @@ -175,7 +175,6 @@ func (p *Plugin) WithName(name string) *Plugin { // Score returns the scoring result for the given list of pods based on context. func (p *Plugin) Score(ctx context.Context, cycleState *types.CycleState, request *types.LLMRequest, pods []types.Pod) map[types.Pod]float64 { - loggerTrace := log.FromContext(ctx).V(logutil.TRACE) // pre score step, hashing prompt and find longest prefix match. hashes := hashPrompt(ctx, request, p.config.HashBlockSize, p.config.MaxPrefixBlocksToMatch) state := &SchedulingContextState{ @@ -185,7 +184,7 @@ func (p *Plugin) Score(ctx context.Context, cycleState *types.CycleState, reques cycleState.Write(plugins.StateKey(p.TypedName().String()), state) p.pluginState.Write(request.RequestId, plugins.StateKey(p.TypedName().String()), state) - loggerTrace.Info(fmt.Sprintf("cached servers: %+v", state.PrefixCacheServers), "hashes", state.PrefixHashes) + log.FromContext(ctx).V(logutil.TRACE).Info("prefix cached state", "cached-servers", state.PrefixCacheServers, "hashes", state.PrefixHashes) // calculate the scores of pods scores := make(map[types.Pod]float64, len(pods)) diff --git a/pkg/epp/scheduling/framework/plugins/picker/max_score_picker.go b/pkg/epp/scheduling/framework/plugins/picker/max_score_picker.go index 90100d7e6..325f735fa 100644 --- a/pkg/epp/scheduling/framework/plugins/picker/max_score_picker.go +++ b/pkg/epp/scheduling/framework/plugins/picker/max_score_picker.go @@ -82,8 +82,8 @@ func (p *MaxScorePicker) TypedName() plugins.TypedName { // Pick selects the pod with the maximum score from the list of candidates. func (p *MaxScorePicker) Pick(ctx context.Context, cycleState *types.CycleState, scoredPods []*types.ScoredPod) *types.ProfileRunResult { - log.FromContext(ctx).V(logutil.DEBUG).Info("Selecting pods from candidates sorted by max score: ", "NumberOfPods", p.maxNumOfEndpoints, - "scoredPodsLength", len(scoredPods), "scoredPods", scoredPods) + log.FromContext(ctx).V(logutil.DEBUG).Info("Selecting pods from candidates sorted by max score", "max-num-of-endpoints", p.maxNumOfEndpoints, + "num-of-candidates", len(scoredPods), "scored-pods", scoredPods) // TODO: merge this with the logic in RandomPicker // Rand package is not safe for concurrent use, so we create a new instance. diff --git a/pkg/epp/scheduling/framework/plugins/picker/random_picker.go b/pkg/epp/scheduling/framework/plugins/picker/random_picker.go index b571ce3a5..c885288eb 100644 --- a/pkg/epp/scheduling/framework/plugins/picker/random_picker.go +++ b/pkg/epp/scheduling/framework/plugins/picker/random_picker.go @@ -80,8 +80,8 @@ func (p *RandomPicker) TypedName() plugins.TypedName { // Pick selects random pod(s) from the list of candidates. func (p *RandomPicker) Pick(ctx context.Context, _ *types.CycleState, scoredPods []*types.ScoredPod) *types.ProfileRunResult { - log.FromContext(ctx).V(logutil.DEBUG).Info(fmt.Sprintf("Selecting maximum '%d' pods from %d candidates randomly: %+v", p.maxNumOfEndpoints, - len(scoredPods), scoredPods)) + log.FromContext(ctx).V(logutil.DEBUG).Info("Selecting pods from candidates randomly", "max-num-of-endpoints", p.maxNumOfEndpoints, + "num-of-candidates", len(scoredPods), "scored-pods", scoredPods) // TODO: merge this with the logic in MaxScorePicker // Rand package is not safe for concurrent use, so we create a new instance. From 73d083380c7446a27a002b2445d850f0d7fd9c30 Mon Sep 17 00:00:00 2001 From: Nir Rozenbaum Date: Thu, 4 Sep 2025 08:30:46 +0300 Subject: [PATCH 2/2] godoc Signed-off-by: Nir Rozenbaum --- pkg/epp/scheduling/framework/plugins/picker/random_picker.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/epp/scheduling/framework/plugins/picker/random_picker.go b/pkg/epp/scheduling/framework/plugins/picker/random_picker.go index c885288eb..87a1747fc 100644 --- a/pkg/epp/scheduling/framework/plugins/picker/random_picker.go +++ b/pkg/epp/scheduling/framework/plugins/picker/random_picker.go @@ -38,6 +38,7 @@ const ( // compile-time type validation var _ framework.Picker = &RandomPicker{} +// RandomPickerFactory defines the factory function for RandomPicker. func RandomPickerFactory(name string, rawParameters json.RawMessage, _ plugins.Handle) (plugins.Plugin, error) { parameters := pickerParameters{MaxNumOfEndpoints: DefaultMaxNumOfEndpoints} if rawParameters != nil {