Skip to content

changing addReplySds and sdscat to addReplyStatusLength() within luaReplyToRedisReply()#11556

Merged
oranagra merged 5 commits intoredis:unstablefrom
filipecosta90:perf.luaReplyToRedisReply
Nov 30, 2022
Merged

changing addReplySds and sdscat to addReplyStatusLength() within luaReplyToRedisReply()#11556
oranagra merged 5 commits intoredis:unstablefrom
filipecosta90:perf.luaReplyToRedisReply

Conversation

@filipecosta90
Copy link
Contributor

@filipecosta90 filipecosta90 commented Nov 29, 2022

profiling EVALSHA after the merge of #11521 ( commit 7dfd7b9 ) we can see that luaReplyToRedisReply takes 8.73% out of the 56.90% of luaCallFunction CPU cycles. The new approach drops luaReplyToRedisReply CPU cycles to 3.77%

image

using addReplyStatusLength instead of directly composing the protocol to avoid sdscatprintf and addReplySds ( which imply multiple sdslen calls ) we get the following improvement on the overall ops/sec:

redis-cli SCRIPT load "redis.call('hset', 'h1', 'k', 'v');redis.call('hset', 'h2', 'k', 'v');return redis.call('ping')"
memtier_benchmark --command="EVALSHA 7cecb99fd9091d8e66d5cccf8979cf3aec5c4951 0" --hide-histogram --test-time 60 --pipeline 10 -x 3
memtier_benchmark --command="eval \"redis.call('hset', 'h1', 'k', 'v');redis.call('hset', 'h2', 'k', 'v');return redis.call('ping')\" 0"  --hide-histogram --test-time 60 --pipeline 10 -x 3
COMMAND 6.2.6 unstable ( 7dfd7b9 ) this PR ( 20403fa ) % Improvement vs unstable % Drop vs 6.2.6
EVAL 223744 187298 198282 5.86% -11.38%
EVALSHA 264411 207848 221750 6.69% -16.13%

@filipecosta90 filipecosta90 added the action:run-benchmark Triggers the benchmark suite for this Pull Request label Nov 29, 2022
Copy link
Member

@oranagra oranagra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so specifically, status replies were inefficient, but other type of replies are ok?
i guess the most common ones are status, bulk, and array.
from all the reply types i see the only one that was composing a protocol rather than calling a helper function was status.

@filipecosta90 filipecosta90 changed the title changing addReplySds and sdscat to addReplyProto within luaReplyToRedisReply() changing addReplySds and sdscat to addReplySimpleString() within luaReplyToRedisReply() Nov 29, 2022
@filipecosta90 filipecosta90 requested a review from sundb November 30, 2022 08:33
@filipecosta90 filipecosta90 changed the title changing addReplySds and sdscat to addReplySimpleString() within luaReplyToRedisReply() changing addReplySds and sdscat to addReplyStatusLength() within luaReplyToRedisReply() Nov 30, 2022
@oranagra oranagra merged commit 68e87eb into redis:unstable Nov 30, 2022
@filipecosta90 filipecosta90 deleted the perf.luaReplyToRedisReply branch December 1, 2022 10:22
@oranagra oranagra mentioned this pull request Dec 11, 2022
oranagra pushed a commit that referenced this pull request Dec 12, 2022
…eplyToRedisReply() (#11556)

profiling EVALSHA\ we see that luaReplyToRedisReply takes 8.73% out of the
56.90% of luaCallFunction CPU cycles.

Using addReplyStatusLength instead of directly composing the protocol to avoid
sdscatprintf and addReplySds ( which imply multiple sdslen calls ).

The new approach drops
luaReplyToRedisReply CPU cycles to 3.77%

(cherry picked from commit 68e87eb)
madolson pushed a commit to madolson/redis that referenced this pull request Apr 19, 2023
…eplyToRedisReply() (redis#11556)

profiling EVALSHA\ we see that luaReplyToRedisReply takes 8.73% out of the
56.90% of luaCallFunction CPU cycles. 

Using addReplyStatusLength instead of directly composing the protocol to avoid
sdscatprintf and addReplySds ( which imply multiple sdslen calls ).

The new approach drops
luaReplyToRedisReply CPU cycles to 3.77%
enjoy-binbin pushed a commit to enjoy-binbin/redis that referenced this pull request Jul 31, 2023
…eplyToRedisReply() (redis#11556)

profiling EVALSHA\ we see that luaReplyToRedisReply takes 8.73% out of the
56.90% of luaCallFunction CPU cycles. 

Using addReplyStatusLength instead of directly composing the protocol to avoid
sdscatprintf and addReplySds ( which imply multiple sdslen calls ).

The new approach drops
luaReplyToRedisReply CPU cycles to 3.77%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action:run-benchmark Triggers the benchmark suite for this Pull Request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants