mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 09:00:51 +00:00
INCR: Modify incremented object in-place when possible.
However we don't try to do this if the integer is already inside a range representable with a shared integer. The performance gain appears to be around ~15% in micro benchmarks, however in the long run this also helps to improve locality, so should have more, hard to measure, benefits.
This commit is contained in:
parent
de10b8d9cc
commit
16559b4615
@ -337,11 +337,21 @@ void incrDecrCommand(redisClient *c, long long incr) {
|
||||
return;
|
||||
}
|
||||
value += incr;
|
||||
|
||||
if (o && o->refcount == 1 && o->encoding == REDIS_ENCODING_INT &&
|
||||
(value < 0 || value >= REDIS_SHARED_INTEGERS) &&
|
||||
value >= LONG_MIN && value <= LONG_MAX)
|
||||
{
|
||||
new = o;
|
||||
o->ptr = (void*)((long)value);
|
||||
} else {
|
||||
new = createStringObjectFromLongLong(value);
|
||||
if (o)
|
||||
if (o) {
|
||||
dbOverwrite(c->db,c->argv[1],new);
|
||||
else
|
||||
} else {
|
||||
dbAdd(c->db,c->argv[1],new);
|
||||
}
|
||||
}
|
||||
signalModifiedKey(c->db,c->argv[1]);
|
||||
notifyKeyspaceEvent(REDIS_NOTIFY_STRING,"incrby",c->argv[1],c->db->id);
|
||||
server.dirty++;
|
||||
|
Loading…
x
Reference in New Issue
Block a user