A113: pick_first: Weighted Random Shuffling#535
Open
apolcyn wants to merge 5 commits intogrpc:masterfrom
Open
Conversation
easwars
reviewed
Jan 27, 2026
ejona86
approved these changes
Jan 27, 2026
| also for Ring Hash | ||
| * Using fixed point Q31 format has predictable bounds on precision, and allows us to continue representing | ||
| weights as integers. Note our math assumes the sum of weights within a grouping does not exceed max uint32, | ||
| which is mandated in the XDS protocol. |
Member
There was a problem hiding this comment.
Somewhere we should say we are preserving the "sum is a uint32" property for the internal weights (after the multiplication). That can be in the CDS section, or in this section. But we should call it out as a thing we are doing on purpose and desire. (It could also be used as an explanation for why we are using unsigned UQ1.31 instead of UQ32)
| This "fix" will not require any changes within Ring Hash LB itself. | ||
|
|
||
| We can continue to represent weights as integers if we represent their normalized values in | ||
| fixed point Q1.31 format. Math as follows (citation due for @ejona): |
Member
There was a problem hiding this comment.
If you're going to use this notation, then it is UQ1.31. Q1.31 is signed.
ejona86
reviewed
Jan 27, 2026
|
|
||
| CDS LB policy and Pick First LB policy behavior changes will be guarded by `GRPC_EXPERIMENTAL_PF_WEIGHTED_SHUFFLING`. | ||
|
|
||
| Barring unexpected issues, this should be enabled by default. |
Member
There was a problem hiding this comment.
"After testing"? (Although unit testing isn't enough...) Or "after the implementation is shown to be stable"? I feel like we've written something like that before, but I don't recall where.
easwars
approved these changes
Jan 28, 2026
dfawley
approved these changes
Jan 30, 2026
easwars
added a commit
to grpc/grpc-go
that referenced
this pull request
Jan 30, 2026
This PR implements the currently in-review gRFC A113: grpc/proposal#535. I've split the PR into logically separate commits to help with the review process. Summary of changes: - Commit 1: simplify the implementation of `groupLocalitiesByPriority` - Change the implementation to use newly added methods in the stdlib `maps` and `slices` package to significantly simplify the implementation (and get rid of an unnecessary test) - Commit 2: Remove code that handles localities and endpoints of weight 0 - Remove unnecessary checks for locality and endpoint weights of `0` in `cluster_resolver`. The xDS client already guarantees that these weights will never be set to `0`. - Commit 3: add the env var GRPC_EXPERIMENTAL_PF_WEIGHTED_SHUFFLING - Commit 4: Weight computation changes in cluster_resolver LB policy - This performs the weight normalization and fixed-point arithmetic specified in A113 - The change here is guarded by the above env var - Ended up duplicating the tests that verify the weight computation behavior. This will make it easier to delete the old tests when the env var is removed. - Commit 5: Fix a broken test in ring_hash due to the new weight computation - Commit 6: Weighted shuffling in pick_first - Contains the changes specified in A113 for the pick_first LB policy - Changes are guarded by the env var RELEASE NOTES: - pickfirst: Add support for weighted random shuffling of endpoints, as described in gRFC A113
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.
No description provided.