RFR: JDK-8180450: secondary_super_cache does not scale well [v5]

Chris Plummer cjplummer at openjdk.org
Thu Mar 21 16:58:25 UTC 2024


On Thu, 21 Mar 2024 14:42:55 GMT, Andrew Haley <aph at openjdk.org> wrote:

>> This PR is a redesign of subtype checking. 
>> 
>> The implementation of subtype checking in the HotSpot JVM is now twenty years old. There have been some performance-related bugs reported, and the only way to fix them is a redesign of the way it works.
>> 
>> So what's changed, so that the old design should be replaced?
>> 
>> Firstly, the computers of today aren't the computers of twenty years ago. It's not merely a matter of speed: the systems are much more parallel, both in the sense of having more cores and each core can run many instructions in parallel. Because of this, the speed ratio between memory accesses and the rate at which we can execute instructions has become wider and wider.
>> 
>> The most severe reported problem is to do with the "secondary supers cache". This is a 1-element per-class cache for interfaces (and arrays of interfaces). Unfortunately, if two threads repeatedly update this cache, the result is that a cache line ping-pongs between cores, causing a severe slowdown. 
>> 
>> Also, the linear search for an interface that is absent means that the entire list of interfaces has to be scanned. This plays badly with newer language features such as JEP 406, pattern matching for switch.
>> 
>> However, the computers of today can help us. The very high instruction-per-cycle rate of a Great Big Out-Of-Order (GBOOO) processor allows us to execute many of the instructions of a hash table lookup in parallel, as long as we avoid dependencies between instructions. 
>> 
>> The solution
>> ------------
>> 
>> We use a hashed lookup of secondary supers. This is a 64-way hash table, with linear probing for collisions. The table is compressed, in that null entries are removed, and the resulting hash table fits into the same secondary supers array as today's unsorted array of secondary supers. This means that existing code in HotSpot that simply does a linear scan of the secondary supers array does not need to be altered.
>> 
>> We add a bitmap field to each Klass object. This bitmap contains an occupancy bit corresponding to each element of the hash table, with a 1 indicating element presence. As well as allowing the hash table to be decompressed, this bimap is used as a simple kind of Bloom Filter. To determine whether a superclass is present, we simply have to check a single bit in the bitmap. If the bit is clear, we know that the superclass is not present. If the bit is set, we have to do a little arithmetic and then consult the hash table.
>> 
>> It works like th...
>
> Andrew Haley has updated the pull request incrementally with one additional commit since the last revision:
> 
>   JDK-8180450: secondary_super_cache does not scale well

Changes requested by cjplummer (Reviewer).

src/hotspot/share/runtime/globals.hpp line 2002:

> 2000:                                                                             \
> 2001:   product(bool, HashSecondarySupers,  false, DIAGNOSTIC,                    \
> 2002:                 "Use hash table to scan secondary supers.")                 \

Fix indent.

src/hotspot/share/runtime/globals.hpp line 2005:

> 2003:                                                                             \
> 2004:   product(bool, VerifySecondarySupers, false, DIAGNOSTIC,                   \
> 2005:           "Use secondary super cache during subtype checks")                \

Did you mean "Verify secondary super cache..."?

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

PR Review: https://git.openjdk.org/jdk/pull/18309#pullrequestreview-1952823901
PR Review Comment: https://git.openjdk.org/jdk/pull/18309#discussion_r1534288014
PR Review Comment: https://git.openjdk.org/jdk/pull/18309#discussion_r1534288738


More information about the hotspot-dev mailing list