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
(improvement)Optimize DCAwareRoundRobinPolicy with host distance caching
Refactor `DCAwareRoundRobinPolicy` to use a Copy-On-Write (COW) strategy for managing host distances.
Key changes:
- Introduce `_hosts_by_distance` to cache `LOCAL` and `REMOTE` hosts, enabling O(1) distance lookups and thread-safe iteration during query planning.
`IGNORED` hosts do not need to be stored in the cache.
- Optimize control plane operations (`on_up`, `on_down`):
- Add `_add_local_distance` and `_remove_local_distance` to handle local DC node changes via atomic dictionary swaps, avoiding full cache rebuilds.
- Update `_refresh_distances` to support partial refreshes, reusing existing `LOCAL` or `REMOTE` structures when only one DC changes.
Signed-off-by: Yaniv Kaul <yaniv.kaul@scylladb.com>
0 commit comments