Are good colors more common than bad colors?
per.liden at oracle.com
Thu Mar 19 07:34:52 UTC 2020
On 3/19/20 1:11 AM, raell at web.de wrote:
> Dear all,
> on slide 35 of the presentation about ZGC by Per Lidén and Stefan Karlsson  it
> is stated that most object references will have the good color. I tried to analyze
> the probability of a non-root reference that is loaded for the first time for
> having a good color:
> A complete cycle has the three phases
> 1. remapping/marking
> 2. relocation
> 3. no gc action (till the next marking/remapping starts)
> In phase 1 'good' means that the right marked bit is set. At the beginning of the phase
> all non-root references are bad, at the end of the phase all are good. So, if a non-root
> reference is selected randomly, it is good with a probability of about 50%.
> In phases 2, 3 'good' means that the remapped bit is set. Since in these phases no remapping
> is done (except by the load barrier), all non-root references are bad. So, if a non-root
> reference is selected randomly, it is good with a probability of 0%.
> Altogether, it seems to me, that in most parts of a cycle a non-root reference will have
> the bad color.
> Of course, I my be missing something. Therefore, I would be interested in an argument, why
> most object references are expected to have a good color.
Your observations are correct. However, applications typically doesn't
load randomly selected references. They tend to load a much smaller
subset of references over and over again, and a reference will only be
bad the first time it's loaded (within the same phase).
From our measurements, the chances of loading a bad pointer (i.e. load
barrier taking the slow path), is on the order of 1 in a million.
> Thank you very much!
>  http://cr.openjdk.java.net/~pliden/slides/ZGC-Jfokus-2018.pdf
More information about the zgc-dev