Dear OpenJDK CoreLibs community,

A significant enhancement to the Java SE hashing-based Map implementations in 
planned for inclusion in Java SE 7u6. All of the hashing based Map 
implementations: HashMap, Hashtable, LinkedHashMap, WeakHashMap and 
ConcurrentHashMap will now use an enhanced hashing algorithm for string keys 
when the capacity of the hash table has ever grown beyond 512 entries. The 
enhanced hashing implementation uses the murmur3 hashing algorithm[1] along 
with random hash seeds and index masks. These enhancements mitigate cases where 
colliding String hash values could result in a performance bottleneck.

In order to provide the greatest opportunity for developers to test 
compatibility with their applications this change will be incorporated into 
JDK7u6 build 12 and JDK8 build 39. Both builds are planned for release next 
week. ***For 7u6 build 12 only, the alternative hashing will be unconditionally 
enabled (always on).*** The threshold default will be reset to the intended 
release default (512) for 7u6 build 13. 

The quick promotion of this change into builds with limited opportunity for 
public review and the special behaviour for build 12 is intended to make it 
easier for developers to test their application compatibility. Feedback on the 
approach, implementation, compatibility and performance is eagerly sought and 
encouraged both before *and after* this change is incorporated into the OpenJDK 
repositories. 

A new system property, jdk.map.althashing.threshold, allows adjustment of the 
threshold for enabling the enhanced hashing algorithm. If changed from the 
default value of 512, the enhanced hashing will be invoked any time after map 
capacity exceeds the value of jdk.map.althashing.threshold. To completely 
disable the enhanced hashing (not recommended), set 
jdk.map.althashing.threshold to -1 or a very large number such as 2^31 -1 
(Integer.MAX_VALUE).

The iteration order of keys, values and entries for hash-based maps where the 
new algorithm has been invoked will vary for each HashMap instance. While the 
Java SE Map documentation makes no promises that iteration order of items 
returned from Maps will be consistent, developers should check if their 
applications have incorrectly created a dependency on the iteration order of 
Map entries, keys or values.

Webrevs for the Java 7u6 and 8 changes are available for download at [2] and 
[3] for your review. There are some important differences between the Java 7 
and 8 implementations of this enhancement. Most specifically in the Java 8 
implementation alternative string hashing is always enabled--no threshold is 
used for enablement and alternative hashing cannot be disabled. (The Java 8 
implementation completely ignores the jdk.map.althashing.threshold system 
property). The Java 8 implementation is also subject to additional refinement 
as Java 8 develops.

If you have any questions or concerns with this planned enhancement, please use 
the corelibs development mailing list, <mailto:core-libs-dev@openjdk.java.net>, 
or you may also respond privately to me if you prefer.

Thanks,

Mike

[1] Murmur3 : https://code.google.com/p/smhasher/wiki/MurmurHash3
[2] althashing "7" webrev : 
http://cr.openjdk.java.net/~mduigou/althashing7/8/webrev/
[3] althashing "8" webrev : 
http://cr.openjdk.java.net/~mduigou/althashing8/8/webrev/

Reply via email to