Skip to content

Remove unnecessary call to trimStringObjectIfNeeded from tryObjectEnc…#11509

Closed
uriyage wants to merge 1 commit into
redis:unstablefrom
uriyage:remove_call_to_sdsRemoveFreeSpace
Closed

Remove unnecessary call to trimStringObjectIfNeeded from tryObjectEnc…#11509
uriyage wants to merge 1 commit into
redis:unstablefrom
uriyage:remove_call_to_sdsRemoveFreeSpace

Conversation

@uriyage

@uriyage uriyage commented Nov 14, 2022

Copy link
Copy Markdown
Contributor

Call trimStringObjectIfNeeded only when using the querybuf as the object's ptr.

Currently, we call trimStringObjectIfNeeded from tryObjectEncoding which is called for all set-commands.

However, the only place where we might allocate a larger than necessary string object is when we use the querybuf itself as the object's value.

trimStringObjectIfNeeded might be expensive as it tries to remove the internal fragmentation (a result of #7875 change).

@oranagra oranagra left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't like this change.
what it does is trim the excess space every time we put a large string into the argv array, even if that string isn't gonna end up retained, i.e. stored into the database.

the approach of the existing code, it to trim it only when we decide to keep it.
i'd rather change the code in trimStringObjectIfNeeded to be smarter and avoid excessive work.
i.e. it tries to get rid of 10% excess, but in fact the the allocator usually has up to 30% internal fragmentation, so this really became out of context when i made #7875.

@uriyage uriyage closed this Nov 27, 2022
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

Successfully merging this pull request may close these issues.

2 participants