Commit 61d569d
authored
*: Implementation of weighted random shuffling (A113) (#8864)
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 A1131 parent 7985bb4 commit 61d569d
File tree
7 files changed
+591
-141
lines changed- balancer
- pickfirst
- internal
- ringhash
- internal
- envconfig
- xds/balancer/clusterresolver
7 files changed
+591
-141
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| 28 | + | |
27 | 29 | | |
28 | 30 | | |
| 31 | + | |
29 | 32 | | |
30 | 33 | | |
31 | 34 | | |
| |||
34 | 37 | | |
35 | 38 | | |
36 | 39 | | |
| 40 | + | |
| 41 | + | |
37 | 42 | | |
38 | 43 | | |
39 | 44 | | |
| |||
258 | 263 | | |
259 | 264 | | |
260 | 265 | | |
261 | | - | |
262 | | - | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
263 | 302 | | |
264 | 303 | | |
265 | 304 | | |
| |||
906 | 945 | | |
907 | 946 | | |
908 | 947 | | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
42 | 43 | | |
| 44 | + | |
43 | 45 | | |
44 | 46 | | |
45 | 47 | | |
| |||
425 | 427 | | |
426 | 428 | | |
427 | 429 | | |
| 430 | + | |
| 431 | + | |
428 | 432 | | |
429 | 433 | | |
430 | 434 | | |
| |||
485 | 489 | | |
486 | 490 | | |
487 | 491 | | |
| 492 | + | |
| 493 | + | |
488 | 494 | | |
489 | 495 | | |
490 | 496 | | |
| |||
560 | 566 | | |
561 | 567 | | |
562 | 568 | | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
563 | 632 | | |
564 | 633 | | |
| 634 | + | |
| 635 | + | |
565 | 636 | | |
566 | 637 | | |
567 | 638 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1240 | 1240 | | |
1241 | 1241 | | |
1242 | 1242 | | |
| 1243 | + | |
1243 | 1244 | | |
1244 | 1245 | | |
1245 | 1246 | | |
1246 | | - | |
1247 | | - | |
1248 | | - | |
1249 | | - | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
1250 | 1251 | | |
1251 | 1252 | | |
1252 | 1253 | | |
1253 | 1254 | | |
1254 | 1255 | | |
1255 | 1256 | | |
1256 | | - | |
| 1257 | + | |
1257 | 1258 | | |
1258 | | - | |
| 1259 | + | |
1259 | 1260 | | |
1260 | 1261 | | |
1261 | 1262 | | |
1262 | 1263 | | |
1263 | | - | |
| 1264 | + | |
1264 | 1265 | | |
1265 | | - | |
| 1266 | + | |
1266 | 1267 | | |
1267 | 1268 | | |
1268 | 1269 | | |
| |||
1289 | 1290 | | |
1290 | 1291 | | |
1291 | 1292 | | |
1292 | | - | |
1293 | | - | |
1294 | | - | |
1295 | | - | |
1296 | | - | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
1297 | 1303 | | |
1298 | 1304 | | |
1299 | 1305 | | |
1300 | 1306 | | |
1301 | | - | |
1302 | | - | |
| 1307 | + | |
| 1308 | + | |
1303 | 1309 | | |
1304 | 1310 | | |
1305 | | - | |
1306 | | - | |
| 1311 | + | |
| 1312 | + | |
1307 | 1313 | | |
1308 | 1314 | | |
1309 | 1315 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
93 | 99 | | |
94 | 100 | | |
95 | 101 | | |
| |||
0 commit comments