RFR: 8180450: secondary_super_cache does not scale well [v13]
Andrew Haley
aph at openjdk.org
Fri Apr 12 14:38:17 UTC 2024
> 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 this:
>
>
> mov sub_klass, [& sub_klass-...
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:
- all: https://git.openjdk.org/jdk/pull/18309/files
- new: https://git.openjdk.org/jdk/pull/18309/files/1518b028..404d99a1
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=18309&range=12
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=18309&range=11-12
Stats: 5 lines in 2 files changed: 3 ins; 1 del; 1 mod
Patch: https://git.openjdk.org/jdk/pull/18309.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/18309/head:pull/18309
PR: https://git.openjdk.org/jdk/pull/18309
More information about the hotspot-dev
mailing list