https://github.com/redis/redis/blob/362f2a84bd67a1b65d810b064163e8432c79138e/src/cluster.c#L4341
as nodes slots metadata is recorded in server.cluster->slots, why not just loop it?
latency of cluster slots increases while amount of nodes in cluster enlarges, which blocks responses of other requests.
Comment From: madolson
@ShooterIT ^ Care to answer
Comment From: ShooterIT
Hi @madolson @KinWaiYuen I think this optimization makes sense. In my opinion, calling too many clusterNodeGetSlotBit in clusterReplyMultiBulkSlots may cause blocking. We could do similar job like https://github.com/redis/redis/pull/8182
USE PROFILER BEFORE OPTIMIZING
But before we do optimize, for cluster slots command analysis @KinWaiYuen would you help me to get some perf info or flame graph by https://github.com/brendangregg/FlameGraph, and we also can compare performance after optimization
Comment From: KinWaiYuen
with a simple modification like this, i found time cost shortens and costs less percentage of cpu time (samples in a 100 node redis cluster).
original:
after modified:
that seems works!
perf graph svg files: cluster_slot_perf_compare.tar.gz
Comment From: madolson
Nice work! This also seems like a more logical implementation all around. Do you wan to post a PR for it?
Comment From: KinWaiYuen
of course ! posted here :)