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

Can redis do memory collection for sds alloc if it is more than its actual length? #6291

Open
houximing opened this issue Aug 1, 2019 · 2 comments

Comments

@houximing
Copy link

If we use append key value, the memory allocation will be based on some principles, such as double the memory allocation. So is there any configuration to set when the alloc memory be collected and reduce to its actual length? or this cannot change until the key expires? Thank you.

@oranagra
Copy link
Member

oranagra commented Aug 1, 2019

@antirez this can actually be considered a bug.
normally, when reading form the client we use sdsMakeRoomFor, but later when placing the object into the db, we do tryObjectEncoding, which trims the excess memory.
But in APPEND command, we do sdscatlen which uses sdsMakeRoomFor, but no trimming.
It can be considered a good idea, if the user is gonna keep appending to that object, but will eventually many times lead to double the memory consumption.

Ideally, instead of trimming the excess, it would be good idea to reallocate to the right length before calling sdscatlen, so that we don't need trimming, and we don't end up re-allocating (and moving all the memory) twice.

@WiFeng
Copy link

WiFeng commented Aug 29, 2019

Add an extra argument in APPEND command ? Let the user decide based on the specific scenario.

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

3 participants