Review Request CR#7118743 : Alternative Hashing for String with Hash-based Maps

Doug Lea dl at
Sat May 26 11:29:25 UTC 2012

On 05/24/12 15:34, Mike Duigou wrote:
> Hello All;
> I have updated the webrevs for alternative hashing for String
> [2] althashing "8" webrev :

Not that it matters at all since they will be changed anyway for
JDK8 CHM, but all of the ConcurrentHashMap diffs of (old)
   int h = hash(key.hashCode());
could instead  be changed to
   int h = (k instanceof String)? k.hash32() ^ hashSeed :  hash(k.hashCode());
without changing hash() method. Which as Remi mentioned, is likely to
have more benefit than you might expect vs offloading mechanics into
revised version of hash(), in part by unburying a megamorphic call and
nullcheck by one level. (This is why it was done this way in the first place.)

Perhaps this applies elsewhere.

(Sometime this summer, I hope to write up something on
the various "little" coding issues that may be applicable
for improving performance of library code. As people
mentioned wrt the similar private accessor case,
most of these issues are not interesting/useful for
application code, but there's no reason not to address
them inside heavily used core libraries. The effects
are difficult to measure in any small set of tests using
these library components, so usually the best course of action
is to avoid known potential performance issues.)


More information about the core-libs-dev mailing list