RFR: 8160302: Reduce number of lambdas created when loading java.util.regex.Pattern

Claes Redestad claes.redestad at oracle.com
Wed Feb 1 17:00:56 UTC 2017


changes to java.util.regex in 9+119 has been cause for a number of startup
regressions due to early use of lambdas, which has both helped motivate
work to reduce the overall cost of lambda initialization[1], while in other
cases the use of regexes could be reconsidered (VersionProps).

While this work and workarounds has helped a lot, the changes to
java.util.regex can still be the cause of noticeable regressions[2] when
using regular expressions that depend on predicates defined in
java.util.regex.CharPredicate, simply because of how this class eagerly
creates a substantial amount of lambdas during clinit.

This patch makes the initialization lazy, which improves startup metrics
without affecting performance of regular use.

Bug: https://bugs.openjdk.java.net/browse/JDK-8160302
Webrev: http://cr.openjdk.java.net/~redestad/8160302/webrev.01/



PS. Yes, I know final is redundant on static methods, and realized I forgot
to remove them after turning constants into methods, but looking at again
it seems there's a convention of defining static methods final in this code
already, so unless there is a lot of outrage I'd like to defer cleaning 
up this
particular bikeshed.

[1] https://bugs.openjdk.java.net/browse/JDK-8086045
[2] 12-15ms startup regressions due to generating and loading up to 60
loaded classes, more early JIT compilations etc..

More information about the core-libs-dev mailing list