0

the result of jstat -gcutil is suitable for generational garbage collection, but how can I count the zgc result?

nzomkxia
  • 1,219
  • 4
  • 16
  • 35

1 Answers1

0

afaik, every GC algorithm implements its own statistics, meaning that is a collector specific output. Yes, ZGC is not generational, as such some of the statistics will not be present, which is normal, but otherwise it simply works?

If I have a sample as :

 public class DeleteMe {

    public static void main(String[] args) {
        for(;;){
            LockSupport.parkNanos(TimeUnit.MILLISECONDS.toNanos(500));
            System.out.println(allocate());
        }
    }

    static int allocate() {
        int [] b = new int[10_000];
        for(int i=0;i<10_000;++i){
            b[i] = i + ThreadLocalRandom.current().nextInt();
        }
        return Arrays.hashCode(b);
    }

}

And then take some snapshots of :

jstat -gcutil <PID>

I do see numbers like:

  S0     S1     E      O      M     CCS    YGC     YGCT    FGC    FGCT    CGC    CGCT     GCT   
   -      -      -  15.38  76.33  74.80      -        -     -        -    63    0.005    0.005

S0/S1/E are blank because they simply don't exist (there is no young generation at all). Same argument stays true for: YGC/YGCT/FGC/FGCT, simply because there is no such thing in ZGC. You can find what they mean here, for example. There is also this Q&A that explains some options that are not present in the documentation above.

Eugene
  • 117,005
  • 15
  • 201
  • 306
  • I can see the change of old generation, but the GCT is always 0 S0 S1 E O M CCS YGC YGCT FGC FGCT CGC CGCT GCT - - - 22.71 98.44 - - - - - - - 0.000 - - - 23.16 98.44 - - - - - - - 0.000 but acordding to the gc log, gc happens very often – nzomkxia Feb 04 '21 at 03:54
  • @nzomkxia let it run more or allocate more, then you will see results there. – Eugene Feb 04 '21 at 03:55
  • I'm doing a stress testing now, gc log shows it happens(with gc,start symbol) at intervals of five seconds, and I can see the change of "O" colum, but "GCT keeps 0 – nzomkxia Feb 04 '21 at 03:59
  • this is how I ran it `java -XX:+UseZGC -XX:+UnlockExperimentalVMOptions -Xmx25m -Xms25m DeleteMe.java`, on jdk-15. – Eugene Feb 04 '21 at 04:01
  • I've try your Demo with JDK11 on linux, but the GCT is still 0 – nzomkxia Feb 04 '21 at 08:21