[Mesa-dev] [PATCH 1/6] glsl: Prehash in refcount hash table to reduce hashing
Ian Romanick
idr at freedesktop.org
Mon May 22 19:19:02 UTC 2017
On 05/22/2017 11:55 AM, Thomas Helland wrote:
> _mesa_hash_table_search is one of our hottest function according to perf.
> Callgrind shows the refcounting as one of the major users of the
> searching functions. We can reduce the pain by prehashing, so that we
> avoid hashing two times when inserting in the table.
>
> On a short shader-db run (with validation disabled) it makes
> 1.2 million of 4.5 million calls to _hash_table_insert come from
> the pre-hashed path.
Did this have any measurable impact on the run time?
> ---
> src/compiler/glsl/ir_variable_refcount.cpp | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/src/compiler/glsl/ir_variable_refcount.cpp b/src/compiler/glsl/ir_variable_refcount.cpp
> index 8306be10b9..bbb4c0ddd7 100644
> --- a/src/compiler/glsl/ir_variable_refcount.cpp
> +++ b/src/compiler/glsl/ir_variable_refcount.cpp
> @@ -79,13 +79,16 @@ ir_variable_refcount_visitor::get_variable_entry(ir_variable *var)
> {
> assert(var);
>
> - struct hash_entry *e = _mesa_hash_table_search(this->ht, var);
> + uint32_t hash = this->ht->key_hash_function(var);
> +
> + struct hash_entry *e =
> + _mesa_hash_table_search_pre_hashed(this->ht, hash, var);
> if (e)
> return (ir_variable_refcount_entry *)e->data;
>
> ir_variable_refcount_entry *entry = new ir_variable_refcount_entry(var);
> assert(entry->referenced_count == 0);
> - _mesa_hash_table_insert(this->ht, var, entry);
> + _mesa_hash_table_insert_pre_hashed(this->ht, hash, var, entry);
>
> return entry;
> }
>
More information about the mesa-dev
mailing list