From: Eric Anholt Date: Fri, 18 Jan 2008 18:15:28 +0000 (-0800) Subject: [965] Do a little bit rotation in state hash to reduce collisions. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2afe5344dfb7b19563046d7b2f522d91335aac66;p=mesa.git [965] Do a little bit rotation in state hash to reduce collisions. This was around 3% improvement in OA. --- diff --git a/src/mesa/drivers/dri/i965/brw_state_cache.c b/src/mesa/drivers/dri/i965/brw_state_cache.c index 315fd9f206d..9e5e6235612 100644 --- a/src/mesa/drivers/dri/i965/brw_state_cache.c +++ b/src/mesa/drivers/dri/i965/brw_state_cache.c @@ -79,14 +79,18 @@ static GLuint hash_key( const void *key, GLuint key_size, /* I'm sure this can be improved on: */ - for (i = 0; i < key_size/4; i++) + for (i = 0; i < key_size/4; i++) { hash ^= ikey[i]; + hash = (hash << 5) | (hash >> 27); + } /* Include the BO pointers as key data as well */ ikey = (void *)reloc_bufs; key_size = nr_reloc_bufs * sizeof(dri_bo *); - for (i = 0; i < key_size/4; i++) + for (i = 0; i < key_size/4; i++) { hash ^= ikey[i]; + hash = (hash << 5) | (hash >> 27); + } return hash; } @@ -111,6 +115,16 @@ search_cache(struct brw_cache *cache, enum brw_cache_id cache_id, { struct brw_cache_item *c; +#if 0 + int bucketcount = 0; + + for (c = cache->items[hash % cache->size]; c; c = c->next) + bucketcount++; + + fprintf(stderr, "bucket %d/%d = %d/%d items\n", hash % cache->size, + cache->size, bucketcount, cache->n_items); +#endif + for (c = cache->items[hash % cache->size]; c; c = c->next) { if (c->cache_id == cache_id && c->hash == hash &&