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

Embed keys and hash fields as SDS type 5 #1613

Draft
wants to merge 4 commits into
base: unstable
Choose a base branch
from

Conversation

zuiderkwast
Copy link
Contributor

Until now, these embedded strings were SDS type 8, because they were copied as-is from EMBSTR encoded string objects, which always use SDS type 8. This change allows them to be embedded as SDS type 5, saving two bytes.

The implementation of embeddeding SDS strings in other structures is refactored. sdswrite() is a new function to create an SDS representation into a buffer provided by the caller, instead of allocating it. sdscopytobuffer() which just copied the layout of an existing sds is deleted.

The DEBUG SDSLEN command output is changed slightly, to account for correct allocation sizes of embedded strings and not report the same memory twice.

Fixes #1567

Until now, these embedded strings were SDS type 8, becuase they were
copied as-is from EMBSTR encoded string objects, which always use SDS
type 8. This change allows them to be embedded as SDS type 5, saving
two bytes.

The implementation of embeddeding SDS strings in other structures is
refactored. sdswrite() is a new function to create an SDS representation
into a buffer provided by the caller, instead of allocating it.
sdscopytobuffer() which just copied the layout of an existing sds is
deleted.

The DEBUG SDSLEN command output is changed slightly, to account for
correct allocation sizes for embedded strings and not report the same
memory twice.

Signed-off-by: Viktor Söderqvist <[email protected]>
@zuiderkwast zuiderkwast requested a review from ranshid January 24, 2025 19:02
@zuiderkwast zuiderkwast changed the title Embed keys in serverObject and fields in hash entry as SDS type 5 Embed keys and hash fields as SDS type 5 Jan 24, 2025
@zuiderkwast zuiderkwast marked this pull request as draft January 24, 2025 19:04
Signed-off-by: Viktor Söderqvist <[email protected]>
Signed-off-by: Viktor Söderqvist <[email protected]>
Signed-off-by: Viktor Söderqvist <[email protected]>
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.

Extra memory consumed by embedded sds in new HashObject fields
1 participant