Skip to content

Commit

Permalink
member: implement HT mode
Browse files Browse the repository at this point in the history
One of the set-summary structures is hash-table based
set-summary (HTSS). One example is cuckoo filter [1].

Comparing to a traditional hash table, HTSS has a much more
compact structure. For each element, only one signature and
its corresponding set ID is stored. No key comparison is required
during lookup. For the table structure, there are multiple entries
in each bucket, and the table is composed of many buckets.

Two modes are supported for HTSS, "cache" and "none-cache" modes.
The non-cache mode is similar to the cuckoo filter [1].
When a bucket is full, one entry will be evicted to its
alternative bucket to make space for the new key. The table could
be full and then no more keys could be inserted. This mode has
false-positive rate but no false-negative. Multiple entries
with same signature could stay in the same bucket.

The "cache" mode does not evict key to its alternative bucket
when a bucket is full, an existing key will be evicted out of
the table like a cache. Thus, the table will never reject keys when
it is full. Another property is in each bucket, there cannot be
multiple entries with same signature. The mode could have both
false-positive and false-negative probability.

This patch adds the implementation of HTSS.

[1] B Fan, D G Andersen and M Kaminsky, “Cuckoo Filter: Practically
Better Than Bloom,” in Conference on emerging Networking
Experiments and Technologies, 2014.

Signed-off-by: Yipeng Wang <[email protected]>
Reviewed-by: Pablo de Lara <[email protected]>
  • Loading branch information
yipengwa authored and tmonjalo committed Oct 8, 2017
1 parent 857ed6c commit 904ec78
Show file tree
Hide file tree
Showing 5 changed files with 627 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/librte_member/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ EXPORT_MAP := rte_member_version.map
LIBABIVER := 1

# all source are stored in SRCS-y
SRCS-$(CONFIG_RTE_LIBRTE_MEMBER) += rte_member.c
SRCS-$(CONFIG_RTE_LIBRTE_MEMBER) += rte_member.c rte_member_ht.c
# install includes
SYMLINK-$(CONFIG_RTE_LIBRTE_MEMBER)-include := rte_member.h

Expand Down
31 changes: 25 additions & 6 deletions lib/librte_member/rte_member.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include <rte_errno.h>

#include "rte_member.h"
#include "rte_member_ht.h"

int librte_member_logtype;

Expand Down Expand Up @@ -96,6 +97,9 @@ rte_member_free(struct rte_member_setsum *setsum)
rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);

switch (setsum->type) {
case RTE_MEMBER_TYPE_HT:
rte_member_free_ht(setsum);
break;
default:
break;
}
Expand Down Expand Up @@ -163,6 +167,9 @@ rte_member_create(const struct rte_member_parameters *params)
setsum->sec_hash_seed = params->sec_hash_seed;

switch (setsum->type) {
case RTE_MEMBER_TYPE_HT:
ret = rte_member_create_ht(setsum, params);
break;
default:
goto error_unlock_exit;
}
Expand Down Expand Up @@ -190,8 +197,9 @@ rte_member_add(const struct rte_member_setsum *setsum, const void *key,
if (setsum == NULL || key == NULL)
return -EINVAL;

(void) set_id;
switch (setsum->type) {
case RTE_MEMBER_TYPE_HT:
return rte_member_add_ht(setsum, key, set_id);
default:
return -EINVAL;
}
Expand All @@ -205,6 +213,8 @@ rte_member_lookup(const struct rte_member_setsum *setsum, const void *key,
return -EINVAL;

switch (setsum->type) {
case RTE_MEMBER_TYPE_HT:
return rte_member_lookup_ht(setsum, key, set_id);
default:
return -EINVAL;
}
Expand All @@ -218,8 +228,10 @@ rte_member_lookup_bulk(const struct rte_member_setsum *setsum,
if (setsum == NULL || keys == NULL || set_ids == NULL)
return -EINVAL;

(void) num_keys;
switch (setsum->type) {
case RTE_MEMBER_TYPE_HT:
return rte_member_lookup_bulk_ht(setsum, keys, num_keys,
set_ids);
default:
return -EINVAL;
}
Expand All @@ -232,8 +244,10 @@ rte_member_lookup_multi(const struct rte_member_setsum *setsum, const void *key,
if (setsum == NULL || key == NULL || set_id == NULL)
return -EINVAL;

(void) match_per_key;
switch (setsum->type) {
case RTE_MEMBER_TYPE_HT:
return rte_member_lookup_multi_ht(setsum, key, match_per_key,
set_id);
default:
return -EINVAL;
}
Expand All @@ -249,9 +263,10 @@ rte_member_lookup_multi_bulk(const struct rte_member_setsum *setsum,
match_count == NULL)
return -EINVAL;

(void) num_keys;
(void) max_match_per_key;
switch (setsum->type) {
case RTE_MEMBER_TYPE_HT:
return rte_member_lookup_multi_bulk_ht(setsum, keys, num_keys,
max_match_per_key, match_count, set_ids);
default:
return -EINVAL;
}
Expand All @@ -264,8 +279,9 @@ rte_member_delete(const struct rte_member_setsum *setsum, const void *key,
if (setsum == NULL || key == NULL)
return -EINVAL;

(void) set_id;
switch (setsum->type) {
case RTE_MEMBER_TYPE_HT:
return rte_member_delete_ht(setsum, key, set_id);
default:
return -EINVAL;
}
Expand All @@ -277,6 +293,9 @@ rte_member_reset(const struct rte_member_setsum *setsum)
if (setsum == NULL)
return;
switch (setsum->type) {
case RTE_MEMBER_TYPE_HT:
rte_member_reset_ht(setsum);
return;
default:
return;
}
Expand Down
1 change: 1 addition & 0 deletions lib/librte_member/rte_member.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ struct rte_member_parameters;
* Define different set summary types
*/
enum rte_member_setsum_type {
RTE_MEMBER_TYPE_HT = 0, /**< Hash table based set summary. */
RTE_MEMBER_NUM_TYPE
};

Expand Down
Loading

0 comments on commit 904ec78

Please sign in to comment.