optimize KlassInfoTable size to power of 2
臧琳
zanglin5 at jd.com
Tue Dec 11 09:53:38 UTC 2018
Hi Andrew,
I understand your concern, thanks for point it out.
I think the reason of not using power of 2 is because it more or less balanced the hash table entries, which
may potentially cause more hash conflict and hence lag the entry lookup speed.
However, in this case for KlassInfoTable, the hash value is the subtraction of klass address with a reference
address, and then 2 bits shift right. Due to the address is limited by the heap size ,I believe that several highest
bits of the hash value are same. So the mod by power of 2 in this case may not hit performance, that maybe
one reason why I observed speedup in my experiment.
And I just did quick test, that using the constant _num_buckets for modulo, gcc issues several instructions instead
of idiv, and the speed up at about 12%, while using 65536 for _number_buckets speedup at 20%.
BRs,
Lin
More information about the serviceability-dev
mailing list