-
Notifications
You must be signed in to change notification settings - Fork 0
[GROW-3598] make initialize to loop through replica nodes per cluster slots row #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #17 +/- ##
==========================================
- Coverage 92.36% 92.34% -0.02%
==========================================
Files 119 119
Lines 30682 30684 +2
==========================================
- Hits 28338 28335 -3
- Misses 2344 2349 +5
☔ View full report in Codecov by Sentry. |
|
for i in range(int(slot[0]), int(slot[1]) + 1): | ||
if i not in tmp_slots: | ||
tmp_slots[i] = [] | ||
tmp_slots[i].append(target_node) | ||
replica_nodes = [slot[j] for j in range(3, len(slot))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replica_nodes = slot[3:]
if we change this line like above, how much does performance change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because all below lines should not affect performance much, I believe. All of its time complexity is O(1)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replica_nodes = slot[3:]
improves the time spent up to 11.043858208024176
the bigger difference came from not iterating through replica nodes by the number of slots
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i know your change is more neat, just curious for python performance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the bigger difference came from not iterating through replica nodes by the number of slots
Hmm? but aren't replica nodes traversed by the number of slots still in your change?
Lines 1577 to 1582 in 2e8fa0c
for i in range(int(slot[0]), int(slot[1]) + 1): | |
if i not in tmp_slots: | |
tmp_slots[i] = [] | |
tmp_slots[i].append(target_node) | |
for target_replica_node in target_replica_nodes: | |
tmp_slots[i].append(target_replica_node) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that part is true, but looking for node doesn't have to be done in those iterations
host = str_if_bytes(replica_node[0])
port = replica_node[1]
host, port = self.remap_host_port(host, port)
target_replica_node = self._get_or_create_cluster_node(host, port, REPLICA, tmp_nodes_cache)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 🤔 🤔 What's wrong with you python. why the 16384 * above operations bring that much performance difference 🐍
@bellatoris i've submitted redis#2943 to redis/redis-py repo as well |
Pull Request check-list
Please make sure to review and check all of these items:
$ tox
pass with this change (including linting)?NOTE: these things are not required to open a PR and can be done
afterwards / while the PR is open.
Description of change
previously
initialize
method was iterating over replica nodes for 16,384 times (number of slots), so it was slow. This PR improves the speed by making the method to iterate for the number ofCLUSTER SLOTS
row.I've ran test on hinge's actual
CLUSTER SLOTS
response and the result and code is show belowresult:
test code: