Re: G1GC: The design choice of prefetching

Liang Mao maoliang.ml at alibaba-inc.com
Tue Oct 15 06:18:47 UTC 2019


Hi Mingyu,

The prefetch design is not only available in new versions of G1 GC but introduced
in very early years in hotspot and other GCs like ParNew. It is kind of aggressive
prefecting imho which prefetches all the addresses in the ref queue which contains
*grey pointers* and also creates enough latency between issuing prefetch instructions
and memory access to maximize the cache utilization. 
There could be the problem you mentioned that cache is evicted if overflowed.
Maintaining the proper length of the ref queue is the way to avoid this. You can
 look into the issue below which fixed this problem and improved performance in G1.
https://bugs.openjdk.java.net/browse/JDK-6672778
OpenJDK developers may correct me if there's something I misunderstood.

Thanks,
Liang



------------------------------------------------------------------
From:Mingyu Wu <timberonce at gmail.com>
Send Time:2019 Oct. 15 (Tue.) 09:34
To:hotspot-gc-dev <hotspot-gc-dev at openjdk.java.net>
Subject:G1GC: The design choice of prefetching

Hi all,
I find that G1GC (in OpenJDK12) implements a method named
*prefetch_and_push*, which prefetches the header and the first field of an
object referenced by a pointer *p *while *p* is about to be enqueued.
However, the effect of this prefetch instruction can be unstable as the
time when the object is processed is unknown. It is possible that many
references are enqueued before *p *(the data structure is actually
First-In-Last-Out) and finally evict the cache line storing the object,
making the prefetch useless. Therefore, what is the design choice of those
prefetch instructions? Do they stand for some tradeoffs related to the
overhead of prefetching?

Thanks,
Mingyu


More information about the hotspot-gc-dev mailing list