Fix performance degradation due to non-caching of command info in Redis 6 Cluster #1355
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What is the problem?
I observed performance degradation when using redis.ClusterClient in Redis 6.
pprof reported the following bottleneck caused by mutex lock (https://github.com/go-redis/redis/blob/a999d1ecd81303df8128547746c62358f78048f5/command.go#L2153-L2154).
This mutex lock is for the client to cache COMMAND reply just once (https://github.com/go-redis/redis/blob/a999d1ecd81303df8128547746c62358f78048f5/cluster.go#L688).
However, I noticed that during the debugging of this performance degradation problem, for some reason the client executed COMMAND command every time.
What caused the problem?
I got the following error that has already reported in #1329 in Redis 6.
This error prevented the internal.once from setting the done flag
(https://github.com/go-redis/redis/blob/a999d1ecd81303df8128547746c62358f78048f5/internal/once.go#L54-L57). As a result, the client did not cache COMMAND reply.
This error is caused by the change of additional command categories in Redis 6.
I show the example of the output of COMMAND and COMMAND INFO reply.
Thus, I have fixed go-redis to handle this 7th elements for additional ACL categories. Finally, I solved my problem of performance degradation.