Commit d73e202
committed
perf: cache session.cluster as local in _set_result to avoid repeated double-lookup
In the ResultMessage hot path, self.session.cluster was accessed 3 times
in the tablet routing block plus additional times in SET_KEYSPACE and
SCHEMA_CHANGE branches. Cache session = self.session and
cluster = session.cluster once at entry to eliminate redundant
attribute-chain lookups.
Also reuse the cached 'session' local for the SET_KEYSPACE and
SCHEMA_CHANGE branches instead of re-reading self.session.
Benchmark (5M iters):
3x self.session.cluster (old): 66.2 ns
1x local + 3x local (new): 39.9 ns
Saving: 26.3 ns (1.66x)1 parent 30e01b8 commit d73e202
2 files changed
Lines changed: 82 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4730 | 4730 | | |
4731 | 4731 | | |
4732 | 4732 | | |
| 4733 | + | |
4733 | 4734 | | |
4734 | 4735 | | |
4735 | 4736 | | |
4736 | | - | |
| 4737 | + | |
4737 | 4738 | | |
4738 | 4739 | | |
4739 | 4740 | | |
4740 | 4741 | | |
4741 | 4742 | | |
4742 | | - | |
| 4743 | + | |
| 4744 | + | |
| 4745 | + | |
| 4746 | + | |
4743 | 4747 | | |
4744 | 4748 | | |
4745 | 4749 | | |
4746 | 4750 | | |
4747 | 4751 | | |
4748 | 4752 | | |
4749 | | - | |
| 4753 | + | |
4750 | 4754 | | |
4751 | 4755 | | |
4752 | | - | |
| 4756 | + | |
4753 | 4757 | | |
4754 | 4758 | | |
4755 | 4759 | | |
| |||
4771 | 4775 | | |
4772 | 4776 | | |
4773 | 4777 | | |
4774 | | - | |
4775 | 4778 | | |
4776 | 4779 | | |
4777 | 4780 | | |
| |||
4786 | 4789 | | |
4787 | 4790 | | |
4788 | 4791 | | |
4789 | | - | |
| 4792 | + | |
4790 | 4793 | | |
4791 | | - | |
| 4794 | + | |
4792 | 4795 | | |
4793 | 4796 | | |
4794 | 4797 | | |
| |||
0 commit comments