Commit 601f065
committed
perf: avoid redundant tablet lookup in shard-aware connection selection
When tablets are in use, get_tablet_for_key() was called twice per
request: once in TokenAwarePolicy.make_query_plan() to find the replica,
and again in HostConnection._get_connection_for_routing_key() to
determine the shard.
Stash the tablet found during query planning on the query object
(query._tablet) and pass it through to borrow_connection(), which
skips the second lookup when a tablet is already available. This
eliminates redundant bisect_left calls and associated dict lookups.1 parent 8e395c7 commit 601f065
3 files changed
Lines changed: 22 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4613 | 4613 | | |
4614 | 4614 | | |
4615 | 4615 | | |
4616 | | - | |
| 4616 | + | |
| 4617 | + | |
| 4618 | + | |
| 4619 | + | |
4617 | 4620 | | |
4618 | 4621 | | |
4619 | 4622 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
511 | 511 | | |
512 | 512 | | |
513 | 513 | | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
514 | 518 | | |
515 | 519 | | |
516 | 520 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
442 | 442 | | |
443 | 443 | | |
444 | 444 | | |
445 | | - | |
| 445 | + | |
446 | 446 | | |
447 | 447 | | |
448 | 448 | | |
| |||
456 | 456 | | |
457 | 457 | | |
458 | 458 | | |
459 | | - | |
460 | | - | |
461 | | - | |
462 | | - | |
463 | | - | |
| 459 | + | |
| 460 | + | |
464 | 461 | | |
465 | 462 | | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
466 | 471 | | |
467 | 472 | | |
468 | 473 | | |
| |||
505 | 510 | | |
506 | 511 | | |
507 | 512 | | |
508 | | - | |
509 | | - | |
| 513 | + | |
| 514 | + | |
510 | 515 | | |
511 | 516 | | |
512 | 517 | | |
513 | 518 | | |
514 | 519 | | |
515 | 520 | | |
516 | | - | |
| 521 | + | |
517 | 522 | | |
518 | 523 | | |
519 | 524 | | |
| |||
0 commit comments