Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Robert Klemme Newsgroups: comp.lang.java.programmer Subject: Re: java8 up to 6x slower than java7 Date: Sun, 16 Feb 2014 13:10:48 +0100 Lines: 44 Message-ID: References: <29a51a94-8f9a-41b1-980f-e8c13e2d11a2@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net rfqLCDNluUY8GwKjZ5BE3gwvsVrvdF8Uzdh+vu1SWuV3WRNrE= Cancel-Lock: sha1:kw1D/k5akQbcFL9BHPYKNY4th1E= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 In-Reply-To: Xref: csiph.com comp.lang.java.programmer:27524 On 15.02.2014 12:52, Jan Burse wrote: > I must admit that I don't use the Java hashmap and have written > a custom version. The reason for this custom version was basically > to allow faster iteration, and not allocating an iterator. This > was already done before JDK 8 came out, independent of JDK 8. I also once wrote a Map using double Hashing. The reason at the time was to avoid the many Entry instances. But we did only replace certain uses of HashMap which we knew would create and GC lots of Entry instances and have rare iterations (Entry instances were created during iteration only, this was the downside). > But I now read that JDK 8 has introduced a new realization > of HashMap. See for example: > > http://blog.credera.com/technology-insights/java/java-8-part-3-hashmap-java-time/ How is this supposed to work for keys which do not implement Comparable? Or are they using the hash code only for the tree arrangement? Also, the article does not mention that the fill factor limits the average length of the chain used for linear probing. It's also not mentioned in the article how they create the tree. You can use an object per node but you can sometimes also use an array. > So I understand that you could see dramatic negative changes. > Sorry to hear that. I am surprised that they do such a dramatic change to a standard library class. In the past Sun / Oracle seemed to always try to minimize the impact on programs. > I will check my code more closely now, and try to eliminate more > of HashMap by my custom code where appropriate. I would first do some analysis before going there to determine how long linear probing is on average. Kind regards robert