antirez / antirez/sds

Some confusions on sdshdr5 & sdshdr8 on key/value actual memory usage and MEMORY USAGE command

未关闭
#111 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
C
星标
5.6k
派生
510
PR 合并指标
30 天内没有已合并 PR

描述

I did some investigation on Redis source code 4.0 while I was doing my job. Something about sdshdr5 and sdshdr8 storage had raised my curiosity and something really confused me popped up. Here are the steps to reproduce the scenario:
1. Open redis cli
2. Type SET key value
3. So here from my perspective and observation, THE value has been stored with sdshdr8 and THE key has been stored with sdshdr5(through dbAdd->sdsdup)
5. I was guessing with the help of MEMORY USAGE, THE key should be analysed as sdshdr5, while THE key was passed via c->argv[2]->ptr, it will be first encapsulated with method createdEmbeddeStringObject which adopt sdshdr8 as the struct type. So it will be analysed as sdshdr8 rather than sdshdr5.
So, could anyone explain what is the actual reason for this and will this affect the accuracy of MEMORY USAGE command? Appreciated

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。