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

New encoding for string: embedded SDS. #543

Closed
antirez opened this Issue Jun 8, 2012 · 1 comment

Comments

Projects
None yet
1 participant
@antirez
Owner

antirez commented Jun 8, 2012

Note: this issue was already implemented in the memopt branch.

Previously two string encodings were used for string objects:

  • REDIS_ENCODING_RAW: a string object with obj->ptr pointing to an sds string.
  • REDIS_ENCODING_INT: a string object where the obj->ptr void pointer is casted to a long.

This commit introduces a experimental new encoding called
REDIS_ENCODING_EMBSTR that implements an object represented by an sds
string that is not modifiable but allocated in the same memory chunk as
the robj structure itself.

The chunk looks like the following:

+--------------+-----------+------------+--------+----+
| robj data... | robj->ptr | sds header | string | \0 |
+--------------+-----+-----+------------+--------+----+
                     |                       ^
                     +-----------------------+

The robj->ptr points to the contiguous sds string data, so the object
can be manipulated with the same functions used to manipulate plan
string objects, however we need just on malloc and one free in order to
allocate or release this kind of objects. Moreover it has better cache
locality.

This new allocation strategy should benefit both the memory usage and
the performances. A performance gain between 60 and 70% was observed
during micro-benchmarks, however there is more work to do to evaluate
the performance impact and the memory usage behavior.

@ghost ghost assigned antirez Jun 8, 2012

@antirez

This comment has been minimized.

Show comment
Hide comment
@antirez

antirez Jul 22, 2013

Owner

Merged, closing.

Owner

antirez commented Jul 22, 2013

Merged, closing.

@antirez antirez closed this Jul 22, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment