[Mesa-dev] [PATCH] mesa: use pre_hashed version of search for the mesa hash table

Eric Anholt eric at anholt.net
Tue Apr 11 01:52:05 UTC 2017


Timothy Arceri <tarceri at itsqueeze.com> writes:

> The key is just an unsigned int so there is never any real hashing
> done.
> ---
>  src/mesa/main/hash.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/src/mesa/main/hash.c b/src/mesa/main/hash.c
> index 670438a..eb25d88 100644
> --- a/src/mesa/main/hash.c
> +++ b/src/mesa/main/hash.c
> @@ -176,21 +176,22 @@ static inline void *
>  _mesa_HashLookup_unlocked(struct _mesa_HashTable *table, GLuint key)
>  {
>     const struct hash_entry *entry;
>  
>     assert(table);
>     assert(key);
>  
>     if (key == DELETED_KEY_VALUE)
>        return table->deleted_key_data;
>  
> -   entry = _mesa_hash_table_search(table->ht, uint_key(key));
> +   uint32_t hash = uint_hash(key);
> +   entry = _mesa_hash_table_search_pre_hashed(table->ht, hash, uint_key(key));
>     if (!entry)
>        return NULL;
>  
>     return entry->data;
>  }

So this cuts out the no-op function call back from the HT code.  Seems
like a win that's worth the bit of complexity in this very hot path.  I
would also be happy with not having the temp and just doing:

entry = _mesa_hash_table_search_pre_hashed(table->ht,
                                           uint_hash(key),
                                           uint_key(key));

which I think looks pretty nice.  Either way,

Reviewed-by: Eric Anholt <eric at anholt.net>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170410/4760e1be/attachment.sig>


More information about the mesa-dev mailing list