OSDN Git Service

mesa: Convert the hash table for GL object ids to the open-addressing hash.
authorEric Anholt <eric@anholt.net>
Wed, 7 Nov 2012 07:18:42 +0000 (23:18 -0800)
committerChad Versace <chad.versace@linux.intel.com>
Mon, 12 Nov 2012 23:52:43 +0000 (15:52 -0800)
commit6991c2922f530d88622900039c24bd04d9c15ce7
tree12696f97f637f858657b53b5abf65c69cddd1332
parent35fd61bd99c15c2e13d3945b41c4db7df6e64319
mesa: Convert the hash table for GL object ids to the open-addressing hash.

The previous 1023-entry chaining hash table never resized, so it was very
inefficient when there were many objects live.  While one could have an even
more efficient implementation than this (keep an array for genned names with
packed IDs, or take advantage of the fact that key == hash or key ==
*(uint32_t *)data to store less data), this is fairly fast, and I want a nice
replacement hash table for other parts of Mesa, too.

It improves Minecraft performance 12.3% +/- 1.4% (n=9), dropping hash lookups
from 8% of the profile to 0.5%.

I also tested cairo-gl, which should be a pessimal workload for this hash
table: around 247000 FBOs created and destroyed, only around 65 live at any
time, and few lookups of them between creation and destruction.  No
statistically significant performance difference at n=76 (mean 20.3/20.4
seconds, sd 2.8/3.2 seconds).  If I remove the >20 seconds outliers that
appear to be due to thermal throttling, there's possibly a .97% +/- 0.31%
performance win (n=61/59).  The choice of cutoff for outliers feels a lot like
cooking the data, but I've gone through this process 3 times for minor
iterations of the code with the same conclusion each time.

Reviewed-by: Brian Paul <brianp@vmware.com>
Acked-by: Chad Versace <chad.versace@linux.intel.com>
Acked-by: Kenneth Graunke <kenneth@whitecape.org> (v1)
src/mesa/main/hash.c
src/mesa/main/hash.h