James Sutherland: “Java performance optimization is part analysis, and part superstition and witch craft.”
In his blog post “What is faster? JVM Performance,” he compares various ways to solve problems in Java and how they perform. For example, how the various map types perform.
What surprised me as well was to poor performance of HashMap. 23% slower than Hashtable…
Another surprise that block synchronized code is twice as expensive as synchronized methods. Tools like FindBugs discourage using synchronized methods.
Or the impact of volatile on field access.