Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update large top-K ratio handling logic #2509

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions pkg/gateway/lb/handler/grpc/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,12 +452,9 @@
// It ensures that the number of results is not less than the minimum required and adjusts based on the provided ratio.
func (s *server) calculateNum(ctx context.Context, num uint32, ratio float32) (n uint32) {
min := float64(s.replica) / float64(len(s.gateway.Addrs(ctx)))
if ratio < 0.0 {
if ratio <= 0.0 {

Check warning on line 455 in pkg/gateway/lb/handler/grpc/handler.go

View check run for this annotation

Codecov / codecov/patch

pkg/gateway/lb/handler/grpc/handler.go#L455

Added line #L455 was not covered by tests
return uint32(math.Ceil(float64(num) * min))
}
if ratio == 0.0 {
return num
}
n = uint32(math.Ceil(float64(num) * (min + ((1 - min) * float64(ratio)))))
sn := uint32(math.Ceil(float64(num) * min))
if n-1 < sn {
Expand Down
Loading