This is an idea of the hash table approach I'd like to use for the main key space.

The picture is taken from https://www.youtube.com/watch?v=ncHmEUmJZf4 at 48:57.
It's an open addressing hash table, consisting of blocks of 64 bytes (one cache line). Each block has space for 7 keys (no values, so it's semantically a set), as shown in the picture. For each key there are 8 hash bits, to quickly eliminate mismatching keys. In addition to that, there's one "presence" bit to indicate whether each of the elements exists or is an empty slot. Finally one "ever full" bit to indicate if the block has ever been full. This is like a shared tombstone and it is the condition to whether probing the next block is necessary. There is no internal order among these 7 keys. A new element can be inserted in the first free slot within the block.
SCAN can work by scanning block-by-block until a block with the "ever full" bit zero.
Incremental rehashing can work the same way as the classic dict, i.e. have two tables allocated during rehash.
The element I want to put in the hash table is a pointer to an object (robj) which is should contain all fields like key, value, TTL, LRU, in a compact way, with or without an embedded key.
Splitting this into tasks:
Regarding changing how TTLs are stored, it's not necessary to do in the scope of repacing the hash table implementation. I'm moving it to a separate issue: #990.
This is an idea of the hash table approach I'd like to use for the main key space.
The picture is taken from https://www.youtube.com/watch?v=ncHmEUmJZf4 at 48:57.
It's an open addressing hash table, consisting of blocks of 64 bytes (one cache line). Each block has space for 7 keys (no values, so it's semantically a set), as shown in the picture. For each key there are 8 hash bits, to quickly eliminate mismatching keys. In addition to that, there's one "presence" bit to indicate whether each of the elements exists or is an empty slot. Finally one "ever full" bit to indicate if the block has ever been full. This is like a shared tombstone and it is the condition to whether probing the next block is necessary. There is no internal order among these 7 keys. A new element can be inserted in the first free slot within the block.
SCAN can work by scanning block-by-block until a block with the "ever full" bit zero.
Incremental rehashing can work the same way as the classic dict, i.e. have two tables allocated during rehash.
The element I want to put in the hash table is a pointer to an object (
robj) which is should contain all fields like key, value, TTL, LRU, in a compact way, with or without an embedded key.Splitting this into tasks:
Regarding changing how TTLs are stored, it's not necessary to do in the scope of repacing the hash table implementation. I'm moving it to a separate issue: #990.