<i18n dev> RFR: 8309622: Re-examine the cache mechanism in BaseLocale [v5]

Naoto Sato naoto at openjdk.org
Wed Aug 30 20:37:42 UTC 2023


On Wed, 30 Aug 2023 06:40:40 GMT, Chen Liang <liach at openjdk.org> wrote:

>> Naoto Sato has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 29 commits:
>> 
>>  - Merge branch 'master' of https://git.openjdk.org/jdk into JDK-8309622-Cache-BaseLocale
>>  - small cleanup
>>  - Merge branch 'pull/14684' into JDK-8309622-Cache-BaseLocale
>>  - Update ReferencedKeyTest.java
>>  - Simple versions of create
>>  - Add flag for reference queue type
>>  - Merge branch 'master' into 8310913
>>  - Update to use VirtualThread friendly stale queue.
>>  - Merge branch 'pull/14684' into JDK-8309622-Cache-BaseLocale
>>  - Remove warning tied to String Templates
>>  - ... and 19 more: https://git.openjdk.org/jdk/compare/7ba8c69a...0e435898
>
> src/java.base/share/classes/sun/util/locale/BaseLocale.java line 96:
> 
>> 94: 
>> 95:     // Non-normalized to normalized BaseLocale cache for saving costly normalizations
>> 96:     private static final Map<BaseLocale, BaseLocale> CACHE = ReferencedKeyMap.create(true, ConcurrentHashMap::new);
> 
> You can now simply use a `ReferencedKeySet<BaseLocale>` and call [`intern(T, UnaryOperator<T>)`](https://github.com/openjdk/jdk/blob/ce2a7ea40a22c652e5f8559c91d5eea197e2d708/src/java.base/share/classes/jdk/internal/util/ReferencedKeySet.java#L202) to cache a normalized variety computed from a non-normalized base.

I need to double-check that it won't cause performance regression, will be visiting this later.

> test/jdk/jdk/internal/util/ReferencedKeyTest.java line 1:
> 
>> 1: /*
> 
> Is the test removal intentional?

Ah, thanks. My bad for unintentionally removing the test.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14404#discussion_r1310790705
PR Review Comment: https://git.openjdk.org/jdk/pull/14404#discussion_r1310790739


More information about the i18n-dev mailing list