From 7f560f8e65a3d9d61b521e26c51d24390ae2e417 Mon Sep 17 00:00:00 2001 From: John Sully Date: Fri, 24 Apr 2020 22:19:55 -0400 Subject: [PATCH] EMBSTR size is lower than it needs to be Former-commit-id: fab6132cb3a0594f6ef65163fcb6f1e0ff8d7587 --- src/object.cpp | 5 +++-- src/storage.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/object.cpp b/src/object.cpp index 77fc1c732..7d07d2de4 100644 --- a/src/object.cpp +++ b/src/object.cpp @@ -127,9 +127,10 @@ robj *createEmbeddedStringObject(const char *ptr, size_t len) { * OBJ_ENCODING_EMBSTR_SIZE_LIMIT, otherwise the RAW encoding is * used. * - * The current limit of 44 is chosen so that the biggest string object + * The current limit of 52 is chosen so that the biggest string object * we allocate as EMBSTR will still fit into the 64 byte arena of jemalloc. */ -#define OBJ_ENCODING_EMBSTR_SIZE_LIMIT 44 +#define OBJ_ENCODING_EMBSTR_SIZE_LIMIT 48 +static_assert((sizeof(redisObject)+OBJ_ENCODING_EMBSTR_SIZE_LIMIT-8) == 64, "Max EMBSTR obj should be 64 bytes total"); robj *createStringObject(const char *ptr, size_t len) { if (len <= OBJ_ENCODING_EMBSTR_SIZE_LIMIT) return createEmbeddedStringObject(ptr,len); diff --git a/src/storage.h b/src/storage.h index 5aee09817..e9106aca2 100644 --- a/src/storage.h +++ b/src/storage.h @@ -1,7 +1,7 @@ #ifndef __STORAGE_H__ #define __STORAGE_H__ -#define OBJ_ENCODING_EMBSTR_SIZE_LIMIT 44 // Note: also defined in object.c - should always match +#define OBJ_ENCODING_EMBSTR_SIZE_LIMIT 48 // Note: also defined in object.c - should always match #ifdef __cplusplus extern "C" {