Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

New encoding for string: embedded SDS. #543

Closed
antirez opened this Issue · 1 comment

1 participant

@antirez
Owner

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.

@antirez antirez was assigned
@antirez
Owner

Merged, closing.

@antirez antirez closed this
@JackieXie168 JackieXie168 referenced this issue from a commit
@srh srh Removed postfix operator++ from bucket_iterator_t. Postfix operators …
…are bad. Mitigates part of issue #543.
1ede877
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.