hash-zipmap-max-entries and HVALS

57 views
Skip to first unread message

Tadeusz Wójcik

unread,
Oct 15, 2011, 10:15:34 AM10/15/11
to Redis DB
Hi,

When using hash-zipmap-max-entries with large value such as 3000-5000
does it make big difference in performance when using only HVALS and
HSET/HMSET commands with hash structure? HVALS is normally O(N), and
when using it with hash-zipmap-max-entries=5000 is it still O(N) or
O(N2)?
Thanks,
Tadek

Didier Spezia

unread,
Oct 16, 2011, 5:11:39 AM10/16/11
to redi...@googlegroups.com
Hi,

the zipmap data structure is described in the comments of:

HVALS is still O(N)

Contrary to a normal hash, zipmap'd HSET is O(N), with a rather high
constant factor when the zipmap must be reallocated and copied.

The higher hash-zipmap-max-entries, the more expensive reallocation/copy
operations will be.

Since only one byte is used to store the size, complexity of zipmap'd
HLEN is also O(N) when N > 253 (while it is constant time for normal hash).
I don't not why. Personally, I would have put at least 2 bytes, to make sure
HLEN is kept constant time for the default size value (512).

Regards,
Didier.

Tadeusz Wójcik

unread,
Oct 17, 2011, 5:21:53 PM10/17/11
to Redis DB
Thanks @Didier, you confirmed my suspicions how it works,
Reply all
Reply to author
Forward
0 new messages