Describe the bug
EVAL_RO and EVALSHA_RO should be faster then EVAL/EVALSHA In some cases it's correct for EVAL_RO/EVAL, but in some it's not but EVALSHA_RO is always slower than EVALSHA
independent of whether the lua uses #!lua flags=no-writes or not
This seems strange?
To reproduce
# using the base example, EVAL_RO is slower than EVAL too
time for i in {1..1000}; do redis-cli EVAL 'return ARGV[1]' 0 hello > /dev/null; done
time for i in {1..1000}; do redis-cli EVAL_RO 'return ARGV[1]' 0 hello > /dev/null; done
time for i in {1..1000}; do redis-cli EVALSHA 098e0f0d1448c0a81dafe820f66d460eb09263da 0 hello > /dev/null; done
time for i in {1..1000}; do redis-cli EVALSHA_RO 098e0f0d1448c0a81dafe820f66d460eb09263da 0 hello > /dev/null; done
# slightly more complex example
redis-cli SET mykey "HELLO;WORLD"
redis-cli SET HELLO "FOO"
redis-cli SET WORLD "BAR"
# EVAL_RO is faster than EVAL but EVALSHA_RO is slower than EVALSHA???
time for i in {1..1000}; do redis-cli EVAL 'local value = redis.call( "GET", KEYS[1] ); local a, b = value:match( "^([^;]+);(.+)$" ); return redis.call( "MGET", a, b )' 1 mykey > /dev/null; done
time for i in {1..1000}; do redis-cli EVAL_RO 'local value = redis.call( "GET", KEYS[1] ); local a, b = value:match( "^([^;]+);(.+)$" ); return redis.call( "MGET", a, b )' 1 mykey > /dev/null; done
time for i in {1..1000}; do redis-cli EVALSH 1a154e0d9707fd5d33c931d40fa139509aec5e42 1 mykey > /dev/null; done
time for i in {1..1000}; do redis-cli EVALSHA_RO 1a154e0d9707fd5d33c931d40fa139509aec5e42 1 mykey > /dev/null; done
Expected behavior
EVALSHA_RO should be faster than EVALSHA
Comment From: sundb
@kkmuffme i don't see any difference between these two commands from the benchmark.
can you try to use redis-benchmark or memtier_benchmark to recheck it?
Comment From: kkmuffme
Is there any documentation on how I can create my own test/run the above commands as test? I only found the basic docs for redis-benchmark of basic commands with a quick check in the docs/google
Comment From: kkmuffme
After some further testing/benchmarking, it seems this is spurious. I was able to replicate the issue 90% of the time with the above example, when doing it with another language (e.g. phpredis), this issue couldn't be replicated.
I guess it's somehow related to redis-cli invocation
Comment From: sundb
Is there any documentation on how I can create my own test/run the above commands as test? I only found the basic docs for redis-benchmark of basic commands with a quick check in the docs/google
./src/redis-benchmark -P 10 -n 10000000 EVAL 'return ARGV[1]' 0 hello or
memtier_benchmark --hide-histogram --test-time 180 --pipeline=10 --command="EVAL 'return ARGV[1]' 0 hello"