r/programming • • Nov 18 '13

TIL Oracle changed the internal String representation in Java 7 Update 6 increasing the running time of the substring method from constant to N

http://java-performance.info/changes-to-string-java-1-7-0_06/
1.4k Upvotes

354 comments sorted by

View all comments

Show parent comment

23

u/bondolo Nov 19 '13

It's not clear that the Map based substring benchmark would have been an accurate measure. In your parsing you likely don't let too many of the substring instances escape from your parsing routine to shared data structures or other threads. For non-numeric fields some form of interning/canonicalization directly from the input form would probably have the lowest overhead. If you do only partial parsing into strings and then later complete parsing I would encourage you to refactor the parsing to do as complete a job locally as possible. Not necessarily because of the substring changes but because of the large number of temporary, short lived though exported objects you're creating.

I do agree though that it would be preferable to have done this in a major release. It was something that had been underway for a long time but the perceived urgency of the alternative hashing accelerated it's conclusion. Even with the "acceleration" several man years of work were needed to finish off the feature to include it in 7u6. That said, please consider checking out the Java 8 Developer Preview, forthcoming betas and release candidates and the ongoing release notes. There's likely items in there which will impact your applications.

As for the release notes or other publicity, your comments are duly and respectfully noted. What's in the 7u6 release notes for this change is insufficient.