Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8227226

ZGC: Segmented array clearing

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P3 P3
    • 14
    • 14
    • hotspot
    • gc
    • b12
    • generic
    • generic

      Filed on behalf of Ryan Sciampacone (sci@amazon.com).

      Reaching a safepoint can be delayed while an array of significant enough size is being cleared. This delay can result in noticeably high pause times which can break ZGC pause time targets.

      This simple (and contrived) example from Stefan Karlsson illustrates the behavior:

      public class BigArrayGC {
            public static Object dummy;
            public static void main(String [] args) {
                  startGcThread();

                  while (true) {
                        dummy = new Object[0x7FFFFFF];
                  }
            }
       
            public static void startGcThread() {
                  Thread t = new Thread() {
                        public void run() {
                              while (true) {
                                    System.gc();
                              }
                        }
                  };
                  t.setDaemon(true);
                  t.start();
            }
      }

      Current output (w/ -Xgc:log) looks something similar to this - which includes allocation stalls:

      [9.825s][info][gc] GC(4) Garbage Collection (System.gc()) 3088M(38%)->7192M(89%)
      [10.666s][info][gc] Allocation Stall (main) 670.200ms
      [10.845s][info][gc] GC(5) Garbage Collection (System.gc()) 7192M(89%)->3088M(38%)
      [11.722s][info][gc] Allocation Stall (main) 3.785ms
      [11.899s][info][gc] GC(6) Garbage Collection (System.gc()) 3088M(38%)->7192M(89%)
      [12.766s][info][gc] Allocation Stall (main) 694.887ms
      [12.944s][info][gc] GC(7) Garbage Collection (System.gc()) 7192M(89%)->3088M(38%)
      [13.812s][info][gc] Allocation Stall (main) 3.738ms

      The expectation is that there would be no stalls:

      [9.610s][info][gc] GC(56) Garbage Collection (System.gc()) 4114M(51%)->4114M(51%)
      [10.205s][info][gc] GC(57) Garbage Collection (System.gc()) 4114M(51%)->5140M(64%)
      [10.565s][info][gc] GC(58) Garbage Collection (System.gc()) 5140M(64%)->4114M(51%)
      [11.257s][info][gc] GC(59) Garbage Collection (System.gc()) 4114M(51%)->4114M(51%)
      [11.939s][info][gc] GC(60) Garbage Collection (System.gc()) 4114M(51%)->6166M(77%)

            pliden Per Liden (Inactive)
            phh Paul Hohensee
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: