perf(picker): guard debug logging to avoid hot-path reflection - #2806
Open
mauriciopoppe wants to merge 1 commit into
Open
perf(picker): guard debug logging to avoid hot-path reflection#2806mauriciopoppe wants to merge 1 commit into
mauriciopoppe wants to merge 1 commit into
Conversation
Contributor
|
🚨 Unsigned commits detected! Please sign your commits. For instructions on how to set up GPG/SSH signing and verify your commits, please see GitHub Documentation. |
…locations Guards debug logging statements across MaxScorePicker, RandomPicker, and WeightedRandomPicker behind logger.V(logutil.DEBUG).Enabled(). When debug logging is disabled (production default), passing scoredEndpoints slices to variadic logging functions forces the Go runtime to allocate variadic argument slices, box parameters into interfaces, and perform slice reflection on the request scheduling hot path. In production profiling on high-concurrency Poisson arrival benchmarks (Qwen3-32B on 2x H100s), guarding this debug log reduced endpoint scheduling overhead and yielded a 47% reduction in TTFT P90 (2.77s to 1.46s). Signed-off-by: Mauricio Poppe <mauriciopoppe@google.com>
mauriciopoppe
force-pushed
the
perf/picker-debug-log-guard
branch
from
September 10, 2026 21:43
95c17af to
2ccf0c6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Guards debug logging statements across
MaxScorePicker,RandomPicker, andWeightedRandomPickerbehindlogger.V(logutil.DEBUG).Enabled()to prevent hot-path heap allocations, interface boxing, and reflection when debug logging is disabled.Problem Localization & Root Cause
During continuous
pprofCPU and heap profiling under high-concurrency Poisson arrival traffic (evaluated on a GKE cluster running Qwen3-32B FP8 across 2x NVIDIA H100 SXM5 GPUs with TP4 and context window B=8192), candidate endpoint selection inpicker.gowas localized as a micro-architectural overhead hotspot on the request scheduling hot path.On every incoming request dispatch,
MaxScorePicker.Pickevaluatedlog.FromContext(ctx).V(logutil.DEBUG).Info(...)unconditionally:Similarly,
RandomPicker.PickandWeightedRandomPicker.Pickevaluated variadic parameters unconditionally on every request.Even when debug logging is disabled at runtime (the production default where log level is INFO), Go evaluates all arguments to a variadic function before executing the call. Passing
"scored-endpoints", scoredEndpoints(wherescoredEndpointsis[]*fwksched.ScoredEndpoint) forces Go's runtime to:[]anyinterface slice for the variadic key-value arguments.scoredEndpointsslice to the heap.This exact issue was previously identified and fixed in
pkg/epp/scheduling/scheduler_profile.go#L201-L213, where guarding the scoring loop reduced total allocations per scheduling call by ~80%:However, the picker plugins themselves (
pkg/epp/framework/plugins/scheduling/picker/) remained unguarded.Empirical Benchmarking Data
Under controlled in-cluster benchmarking (1,155 requests under high-concurrency Poisson arrival load on 2x H100s), comparing the un-modified binary baseline (
v000) against the source-optimized binary (v005):v000)v005)Eliminating heap allocations in the endpoint picker cut TTFT P90 nearly in half (-47.1% reduction from 2.77s down to 1.46s) by reducing GC churn and scheduling latency during traffic bursts.
Changes Included
MaxScorePicker.Picklogging behindif logger.V(logutil.DEBUG).Enabled().RandomPicker.Picklogging behindif logger.V(logutil.DEBUG).Enabled().WeightedRandomPicker.Picklogging behindif logger.V(logutil.DEBUG).Enabled().BenchmarkMaxScorePicker_Picktopkg/epp/framework/plugins/scheduling/picker/maxscore/picker_test.goto provide ongoing allocation tracking.Which issue(s) this PR fixes:
Fixes #
Release note (write
NONEif no user-facing change):