-
I encountered an issue when setting keys with similar values in my Redis environment (version 7.0). Specifically, I ran the following commands: 127.0.0.1:6379> set aaaaaa abcdef
OK
127.0.0.1:6379> set aaaaaaa abcdef
OK
127.0.0.1:6379> memory usage aaaaaa
(integer) 64
127.0.0.1:6379> memory usage aaaaaaa
(integer) 72 This led me to the following questions:
I attempted to calculate it myself using the following logic:
However, even with these calculations, the total memory usage exceeds 64 bytes. Could you help me understand where I might be going wrong? Feel free to ask if you need further clarification or have any additional questions! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 9 replies
-
In jemalloc, aaaaaa falls into bin 8, whereas aaaaaaa falls into bin 16. ref
|
Beta Was this translation helpful? Give feedback.
- 760C
no, key was saved as sds, not robj, so it's 8B.
there are two cases here:
OBJ_ENCODING_RAW
encoding, consume 24B.OBJ_ENCODING_EMBSTR
encoding, consume 32B, becauserobj
andsds
are in contiguous memory, occupying a total of 24 bytes, so they are allocated to bin 32so the memory is (24B or 32B) + 8B + 24B(dictEntry)