summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2020-06-03 12:51:31 +0200
committerantirez <antirez@gmail.com>2020-06-10 10:40:18 +0200
commit4ab662f671d65bd51356b240b3a91aa87eda2767 (patch)
treefc3afc52c1832d48dc832774829e9cbc63923051
parent438ffcae896fcfd19f009cebf2bf8d591e533dad (diff)
downloadredis-4ab662f671d65bd51356b240b3a91aa87eda2767.tar.gz
TCC: LRANGE: use threaded execution only for listlen > N.
-rw-r--r--src/t_list.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/t_list.c b/src/t_list.c
index c5df75252..251046299 100644
--- a/src/t_list.c
+++ b/src/t_list.c
@@ -426,6 +426,7 @@ void lrangeThreadedHalf(client *c, void *options) {
zfree(options);
}
+#define LRANGE_THREADED_THRESHOLD 1000
void lrangeCommand(client *c) {
robj *o;
long start, end, llen, rangelen;
@@ -454,7 +455,9 @@ void lrangeCommand(client *c) {
struct lrangeThreadOptions *opt = zmalloc(sizeof(*opt));
opt->start = start;
opt->rangelen = rangelen;
- if (lockKey(c,c->argv[1],LOCKEDKEY_READ,&opt->o) == C_ERR) {
+ if (llen <= LRANGE_THREADED_THRESHOLD ||
+ lockKey(c,c->argv[1],LOCKEDKEY_READ,&opt->o) == C_ERR)
+ {
/* In the case of LRANGE, we execute the command synchronously
* if we are unable to get a lock. */
lrangeThreadedHalf(c,opt);