* Lai Jiangshan ([email protected]) wrote:
> Signed-off-by: Lai Jiangshan <[email protected]>
> ---
>  rculfhash.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/rculfhash.c b/rculfhash.c
> index eca3a4e..71ef411 100644
> --- a/rculfhash.c
> +++ b/rculfhash.c
> @@ -880,6 +880,7 @@ struct cds_lfht_node *_cds_lfht_add(struct cds_lfht *ht,
>                               goto gc_node;
>                       if ((mode == ADD_UNIQUE || mode == ADD_REPLACE)
>                           && !is_dummy(next)
> +                         && clear_flag(iter)->p.reverse_hash == 
> node->p.reverse_hash
>                           && !ht->compare_fct(node->key, node->key_len,
>                                               clear_flag(iter)->key,
>                                               clear_flag(iter)->key_len)) {
> @@ -1329,6 +1330,7 @@ void cds_lfht_lookup(struct cds_lfht *ht, void *key, 
> size_t key_len,
>               next = rcu_dereference(node->p.next);
>               if (likely(!is_removed(next))
>                   && !is_dummy(next)
> +                 && clear_flag(next)->p.reverse_hash == reverse_hash

nice optimisation. Indeed, we can skip the compare fct calls in many cases,
which will help for long chains.

However, the line above should be comparing:

 clear_flag(node)->p.reverse_hash == reverse_hash

(not next)

>                   && likely(!ht->compare_fct(node->key, node->key_len, key, 
> key_len))) {
>                               break;

also, cds_lfht_next_duplicate() should be modified in the same way.

Thanks,

Mathieu

>               }
> -- 
> 1.7.4.4
> 

-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com

_______________________________________________
ltt-dev mailing list
[email protected]
http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev

Reply via email to