Redis HLL has a 16 bytes header:
- 8 bytes are used to cache the set cardinality
- 3 are not used
- 4 are used to store the magic "HYLL"
- 1 is used to represent the type of the set (sparse or dense)
struct hllhdr {
char magic[4]; /* "HYLL" */
uint8_t encoding; /* HLL_DENSE or HLL_SPARSE. */
uint8_t notused[3]; /* Reserved for future use, must be zero. */
uint8_t card[8]; /* Cached cardinality, little endian. */
uint8_t registers[]; /* Data bytes. */
};
https://github.com/antirez/redis/blob/unstable/src/hyperloglog.c#L182-L188
A set with 1 element takes 21 bytes of memory:
127.0.0.1:6379> PFADD foo bar
(integer) 1
127.0.0.1:6379> STRLEN foo
(integer) 21