Richard Searle's Blog

Thoughts about software

Archive for September, 2012

Java 7u6 String performance regression

Posted by eggsearle on September 13, 2012

I recently updated to Java 7u5 and found a > 10 times degradation in  the performance of some Scala parser combinator code. Some searching turned up a similar experience and bug report

Comparing the 7u5 and 7u6 code indicates a significant change in the implementation.

The older code used a char[] value, with indices. The substring/subsequence operations created a new instance that shared the value, and only changed the indices. The new implementation only has the char[] value, requiring a new copy to be created for every operation!

This change is not referenced in the release notes and the comments within the code do not provide any explanation.  

The Scala parser fortunately uses CharSequence, allowing the creation of a decorator over the String that restores the original behavior. 



Posted in Uncategorized | 6 Comments »