You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
perf: eliminate bisect key= callback via parallel token index lists
Maintain parallel _first_tokens and _last_tokens dicts alongside
_tablets, each mapping (keyspace, table) to a plain list[int]. This
lets bisect_left run entirely in C on native ints instead of calling
an attrgetter callback on every comparison during binary search.
Follow-up to PR #757 which identified the opportunity: its own
benchmarks showed bisect_left without key= is 2.7-5.7x faster than
with key=attrgetter.
Results (best-of-5, Python 3.14):
get_tablet_for_key (hit):
Tablets Before After Saved Speedup
10 293ns 216ns 78ns 1.36x
100 351ns 233ns 118ns 1.51x
1,000 448ns 267ns 181ns 1.68x
10,000 537ns 282ns 255ns 1.90x
All three dicts are kept in sync by add_tablet, drop_tablets, and
drop_tablets_by_host_id. The attrgetter imports are no longer needed
and have been removed.
0 commit comments