[ltt-dev] [PATCH 9/9] rculfhash: compare hash value before call compare_fct()
Mathieu Desnoyers
mathieu.desnoyers at efficios.com
Fri Oct 14 10:22:28 EDT 2011
* Lai Jiangshan (laijs at cn.fujitsu.com) wrote:
> Signed-off-by: Lai Jiangshan <laijs at cn.fujitsu.com>
> ---
> 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
More information about the lttng-dev
mailing list