RFR: 8316493: Remove the caching fields in AbstractMap [v10]

ExE Boss duke at openjdk.org
Thu Oct 26 12:24:38 UTC 2023


On Thu, 19 Oct 2023 13:36:01 GMT, Per Minborg <pminborg at openjdk.org> wrote:

>> This PR outlines a solution for making immutable maps `@ValueBased` by removing cacheing of certain values in `AbstractMap`.
>> 
>> By removing these caching fields in `AbstractMap`, we can make the immutable maps `@ValueBased` and at the same time, performance is likely improved because the JVM is probably able to optimize away object creation anyway via escape analysis. Also, all maps will occupy less space as we get rid of a number of objects and references stored for each map.
>> 
>> We need to benchmark this solution to better understand its implications.
>
> Per Minborg has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Remove caching in TreeMap

src/java.base/share/classes/java/util/TreeMap.java line 1099:

> 1097:      */
> 1098:     private transient EntrySet entrySet;
> 1099:         private transient NavigableMap<K,V> descendingMap;

Suggestion:

    private transient NavigableMap<K,V> descendingMap;

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

PR Review Comment: https://git.openjdk.org/jdk/pull/15614#discussion_r1373080767


More information about the core-libs-dev mailing list