_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. --- 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; } -- 2.13.0 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev