summaryrefslogtreecommitdiff
path: root/src/server.h
diff options
context:
space:
mode:
authoruriyage <78144248+uriyage@users.noreply.github.com>2023-02-28 19:38:58 +0200
committerGitHub <noreply@github.com>2023-02-28 19:38:58 +0200
commit9d336ac398d3a28f6e5e76f1b3b110bab949bcc5 (patch)
tree0925b307d0459a816ae002a0e569a7c80110675f /src/server.h
parentb1939b052adc058bd814045a745ec02d3f791d7b (diff)
downloadredis-9d336ac398d3a28f6e5e76f1b3b110bab949bcc5.tar.gz
Try to trim strings only when applicable (#11817)
As `sdsRemoveFreeSpace` have an impact on performance even if it is a no-op (see details at #11508). Only call the function when there is a possibility that the string contains free space. * For strings coming from the network, it's only if they're bigger than PROTO_MBULK_BIG_ARG * For strings coming from scripts, it's only if they're smaller than LUA_CMD_OBJCACHE_MAX_LEN * For strings coming from modules, it could be anything. Co-authored-by: Oran Agra <oran@redislabs.com> Co-authored-by: sundb <sundbcn@gmail.com>
Diffstat (limited to 'src/server.h')
-rw-r--r--src/server.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/server.h b/src/server.h
index 7d8e65b36..36cd8c760 100644
--- a/src/server.h
+++ b/src/server.h
@@ -2709,7 +2709,7 @@ int compareStringObjects(const robj *a, const robj *b);
int collateStringObjects(const robj *a, const robj *b);
int equalStringObjects(robj *a, robj *b);
unsigned long long estimateObjectIdleTime(robj *o);
-void trimStringObjectIfNeeded(robj *o);
+void trimStringObjectIfNeeded(robj *o, int trim_small_values);
#define sdsEncodedObject(objptr) (objptr->encoding == OBJ_ENCODING_RAW || objptr->encoding == OBJ_ENCODING_EMBSTR)
/* Synchronous I/O with timeout */
@@ -3279,6 +3279,9 @@ typedef struct luaScript {
uint64_t flags;
robj *body;
} luaScript;
+/* Cache of recently used small arguments to avoid malloc calls. */
+#define LUA_CMD_OBJCACHE_SIZE 32
+#define LUA_CMD_OBJCACHE_MAX_LEN 64
/* Blocked clients API */
void processUnblockedClients(void);