Skip to content

Commit 859f32d

Browse files
committed
follow up - improving logging perf issues in few more places (#1528)
* removed fmt.Sprintf from scheduler plugins Signed-off-by: Nir Rozenbaum <[email protected]> * godoc Signed-off-by: Nir Rozenbaum <[email protected]> --------- Signed-off-by: Nir Rozenbaum <[email protected]>
1 parent 13041fe commit 859f32d

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

pkg/epp/scheduling/framework/plugins/multi/prefix/plugin.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ func (p *Plugin) WithName(name string) *Plugin {
175175

176176
// Score returns the scoring result for the given list of pods based on context.
177177
func (p *Plugin) Score(ctx context.Context, cycleState *types.CycleState, request *types.LLMRequest, pods []types.Pod) map[types.Pod]float64 {
178-
loggerTrace := log.FromContext(ctx).V(logutil.TRACE)
179178
// pre score step, hashing prompt and find longest prefix match.
180179
hashes := hashPrompt(ctx, request, p.config.HashBlockSize, p.config.MaxPrefixBlocksToMatch)
181180
state := &SchedulingContextState{
@@ -185,7 +184,7 @@ func (p *Plugin) Score(ctx context.Context, cycleState *types.CycleState, reques
185184

186185
cycleState.Write(plugins.StateKey(p.TypedName().String()), state)
187186
p.pluginState.Write(request.RequestId, plugins.StateKey(p.TypedName().String()), state)
188-
loggerTrace.Info(fmt.Sprintf("cached servers: %+v", state.PrefixCacheServers), "hashes", state.PrefixHashes)
187+
log.FromContext(ctx).V(logutil.TRACE).Info("prefix cached state", "cached-servers", state.PrefixCacheServers, "hashes", state.PrefixHashes)
189188
// calculate the scores of pods
190189
scores := make(map[types.Pod]float64, len(pods))
191190

pkg/epp/scheduling/framework/plugins/picker/max_score_picker.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ func (p *MaxScorePicker) TypedName() plugins.TypedName {
8282

8383
// Pick selects the pod with the maximum score from the list of candidates.
8484
func (p *MaxScorePicker) Pick(ctx context.Context, cycleState *types.CycleState, scoredPods []*types.ScoredPod) *types.ProfileRunResult {
85-
log.FromContext(ctx).V(logutil.DEBUG).Info("Selecting pods from candidates sorted by max score: ", "NumberOfPods", p.maxNumOfEndpoints,
86-
"scoredPodsLength", len(scoredPods), "scoredPods", scoredPods)
85+
log.FromContext(ctx).V(logutil.DEBUG).Info("Selecting pods from candidates sorted by max score", "max-num-of-endpoints", p.maxNumOfEndpoints,
86+
"num-of-candidates", len(scoredPods), "scored-pods", scoredPods)
8787

8888
// TODO: merge this with the logic in RandomPicker
8989
// Rand package is not safe for concurrent use, so we create a new instance.

pkg/epp/scheduling/framework/plugins/picker/random_picker.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const (
3838
// compile-time type validation
3939
var _ framework.Picker = &RandomPicker{}
4040

41+
// RandomPickerFactory defines the factory function for RandomPicker.
4142
func RandomPickerFactory(name string, rawParameters json.RawMessage, _ plugins.Handle) (plugins.Plugin, error) {
4243
parameters := pickerParameters{MaxNumOfEndpoints: DefaultMaxNumOfEndpoints}
4344
if rawParameters != nil {
@@ -80,8 +81,8 @@ func (p *RandomPicker) TypedName() plugins.TypedName {
8081

8182
// Pick selects random pod(s) from the list of candidates.
8283
func (p *RandomPicker) Pick(ctx context.Context, _ *types.CycleState, scoredPods []*types.ScoredPod) *types.ProfileRunResult {
83-
log.FromContext(ctx).V(logutil.DEBUG).Info(fmt.Sprintf("Selecting maximum '%d' pods from %d candidates randomly: %+v", p.maxNumOfEndpoints,
84-
len(scoredPods), scoredPods))
84+
log.FromContext(ctx).V(logutil.DEBUG).Info("Selecting pods from candidates randomly", "max-num-of-endpoints", p.maxNumOfEndpoints,
85+
"num-of-candidates", len(scoredPods), "scored-pods", scoredPods)
8586

8687
// TODO: merge this with the logic in MaxScorePicker
8788
// Rand package is not safe for concurrent use, so we create a new instance.

0 commit comments

Comments
 (0)