Commit 4ab662f6 authored by antirez's avatar antirez
Browse files

TCC: LRANGE: use threaded execution only for listlen > N.

parent 438ffcae
...@@ -426,6 +426,7 @@ void lrangeThreadedHalf(client *c, void *options) { ...@@ -426,6 +426,7 @@ void lrangeThreadedHalf(client *c, void *options) {
zfree(options); zfree(options);
} }
#define LRANGE_THREADED_THRESHOLD 1000
void lrangeCommand(client *c) { void lrangeCommand(client *c) {
robj *o; robj *o;
long start, end, llen, rangelen; long start, end, llen, rangelen;
...@@ -454,7 +455,9 @@ void lrangeCommand(client *c) { ...@@ -454,7 +455,9 @@ void lrangeCommand(client *c) {
struct lrangeThreadOptions *opt = zmalloc(sizeof(*opt)); struct lrangeThreadOptions *opt = zmalloc(sizeof(*opt));
opt->start = start; opt->start = start;
opt->rangelen = rangelen; 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 /* In the case of LRANGE, we execute the command synchronously
* if we are unable to get a lock. */ * if we are unable to get a lock. */
lrangeThreadedHalf(c,opt); lrangeThreadedHalf(c,opt);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment