<i18n dev> RFR: 8331932: Startup regressions in 23-b13

Chen Liang liach at openjdk.org
Wed May 8 15:11:58 UTC 2024


On Wed, 8 May 2024 14:53:05 GMT, Claes Redestad <redestad at openjdk.org> wrote:

> A rather large startup regression was introduced in 23-b13 from [JDK-8309622](https://bugs.openjdk.org/browse/JDK-8309622). Some of that has been dealt with as enhancements such as [JDK-8330802](https://bugs.openjdk.org/browse/JDK-8330802), [JDK-8330595](https://bugs.openjdk.org/browse/JDK-8330595) and [JDK-8330681](https://bugs.openjdk.org/browse/JDK-8330681), which provide both point fixes and reduce initialization overhead of certain constructs more generally. The remaining issues stem from a set of lambdas added in code for `java.util.Locale` and `jdk.internal.util.BaseLocale` causing early bootstrapping of the lambda infrastructure and a bit of class generation.
> 
> While the remaining overheads are relatively small and borderline acceptable (< 2-3ms), I think it's still worth acting on them in this particular case since the amount of added bootstrapping overhead is dependent on which locale the system runs under, which complicates testing and comparisons due to relatively large differences in paths taken on different systems.

src/java.base/share/classes/java/util/Locale.java line 1001:

> 999:             = ReferencedKeyMap.create(true, ReferencedKeyMap.concurrentHashMapSupplier());
> 1000: 
> 1001:     private static final LocaleKey LOCALE_LOOKUP = new LocaleKey();

Reusing an existing class with a special instance for functional interface implementation is weird, I still wonder if we can do the local class + singleton (essentially same as non-capturing lambda) approach.

src/java.base/share/classes/sun/util/locale/BaseLocale.java line 168:

> 166:         return CACHE.intern(new BaseLocale(language, script, region, variant),
> 167:                 // Avoid lambdas since this may be on the bootstrap path in many locales
> 168:                 new UnaryOperator<BaseLocale>() {

Since this intern is called many times, can we convert this `new` to a local class in a static method and reuse its singleton?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/19140#discussion_r1594201610
PR Review Comment: https://git.openjdk.org/jdk/pull/19140#discussion_r1594199711


More information about the i18n-dev mailing list