Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
houximing opened this issue Jul 20, 2019 · 1 comment

Comments

@houximing
Copy link

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)
  4. 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
@houximing
Copy link
Author

houximing commented Jul 20, 2019

Also, there is another question which might sound silly. Why we use 1<<5 (32) as one of the threshold for struct usage variation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant