Understanding ZGC details
per.liden at oracle.com
Sat Jul 14 14:08:29 UTC 2018
On 2018-07-13 19:35, Simone Bordet wrote:
> first of all congrats and thanks for ZGC.
> I've been running a benchmark of mine
> (https://docs.cometd.org/current/reference/#_benchmarking), a
> Servlet-based chat application on top of Jetty, to compare G1,
> Shenandoah and ZGC.
> The hope is to produce some conference material to spread the word
> about ZGC (for which personally I have high expectations).
> Meanwhile I'm trying to understand a bit more about ZGC and I have few
> questions (I have read the GC handbook from Jones et al., but I'm new
> to Linux memory tricks so please pardon my ignorance on the matter; I
> have also watched Per's presentation at JFokus 2018).
> I don't quite get the mechanism of colored pointers and how it exactly works.
> I see that ZGC maps the heap space into 3 views (in
> What is the purpose of mapping into 3 views (I get the number 3, it's
> for the number of phases; but why cannot they be handled with just 1
> Skimming around in the code - not deeply, I admit - seems to be that
> pointers to those views are always de-colored before being
> dereferenced, so I am a bit puzzled about those 3 views.
Actually, pointers are not de-colored, which is the reason why we need
the three heap views on x86 (where we also don't have HW support for
VA-masking/de-coloring). Slide 33 in the JFokus slide pack tries to
(Internally in ZGC we sometimes remove the colors and the heap base, and
we call the result of that an "offset". These "offsets" are however a
pure internal thing and these are never exposed to or used by Java threads).
> Assuming I'm wrong, is the mechanism similar to C4, where a view is
> mprotect()-ed on a phase flip?
> If so, I am also assuming that this would generate a SEGV that will
> run some code that will fix the pointer. Can you please detail where
> is the SEGV handling code that does that?
I think Gil might have answered this already, but just to reiterate, ZGC
does not use SEGV to catch bad pointers. The load barrier (the
test-and-jump instruction sequence) will catch all pointers with "bad"
colors before they are used.
(I'm on vacation at the moment, so my e-mail responsiveness might not be
super good during the next two weeks)
> I'm stopping here feeling that I'm offroad already :)
> I'm sure if you put me back on the road I'll have more questions.
More information about the zgc-dev