hotspot/test/gc/g1/TestG1TraceEagerReclaimHumongousObjects.java
author tschatzl
Tue, 19 Jul 2016 10:31:41 +0200
changeset 39979 b17e445924da
parent 36851 03e2f4d0a421
child 40631 ed82623d7831
permissions -rw-r--r--
8034842: Parallelize the Free CSet phase in G1 Reviewed-by: jmasa, ehelin
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
27151
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
     1
/*
35866
92d36ce7897d 8147940: Test gc/g1/TestG1TraceEagerReclaimHumongousObjects.java fails
david
parents: 35061
diff changeset
     2
 * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
27151
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
     4
 *
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
     7
 * published by the Free Software Foundation.
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
     8
 *
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    13
 * accompanied this code).
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    14
 *
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    18
 *
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    21
 * questions.
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    22
 */
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    23
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    24
/*
28379
e6784fc8fff2 8048179: Early reclaim of large objects that are referenced by a few objects
tschatzl
parents: 27151
diff changeset
    25
 * @test TestG1TraceEagerReclaimHumongousObjects
e6784fc8fff2 8048179: Early reclaim of large objects that are referenced by a few objects
tschatzl
parents: 27151
diff changeset
    26
 * @bug 8058801 8048179
e6784fc8fff2 8048179: Early reclaim of large objects that are referenced by a few objects
tschatzl
parents: 27151
diff changeset
    27
 * @summary Ensure that the output for a G1TraceEagerReclaimHumongousObjects
27151
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    28
 * includes the expected necessary messages.
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    29
 * @key gc
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    30
 * @library /testlibrary
36851
03e2f4d0a421 8153737: Unsupported Module
chegar
parents: 35866
diff changeset
    31
 * @modules java.base/jdk.internal.misc
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 28379
diff changeset
    32
 *          java.management
27151
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    33
 */
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    34
30604
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 29678
diff changeset
    35
import jdk.test.lib.ProcessTools;
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 29678
diff changeset
    36
import jdk.test.lib.OutputAnalyzer;
27151
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    37
import java.util.LinkedList;
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    38
28379
e6784fc8fff2 8048179: Early reclaim of large objects that are referenced by a few objects
tschatzl
parents: 27151
diff changeset
    39
public class TestG1TraceEagerReclaimHumongousObjects {
27151
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    40
  public static void main(String[] args) throws Exception {
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    41
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    42
                                               "-Xms128M",
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    43
                                               "-Xmx128M",
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    44
                                               "-Xmn16M",
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    45
                                               "-XX:G1HeapRegionSize=1M",
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 30604
diff changeset
    46
                                               "-Xlog:gc+phases=trace,gc+humongous=trace",
27151
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    47
                                               "-XX:+UnlockExperimentalVMOptions",
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    48
                                               GCWithHumongousObjectTest.class.getName());
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    49
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    50
    OutputAnalyzer output = new OutputAnalyzer(pb.start());
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    51
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    52
    // As G1ReclaimDeadHumongousObjectsAtYoungGC is set(default), below logs should be displayed.
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 30604
diff changeset
    53
    output.shouldContain("Humongous Reclaim");
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 30604
diff changeset
    54
    output.shouldContain("Humongous Total");
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 30604
diff changeset
    55
    output.shouldContain("Humongous Candidate");
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 30604
diff changeset
    56
    output.shouldContain("Humongous Reclaimed");
27151
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    57
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    58
    // As G1TraceReclaimDeadHumongousObjectsAtYoungGC is set and GCWithHumongousObjectTest has humongous objects,
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    59
    // these logs should be displayed.
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    60
    output.shouldContain("Live humongous");
28379
e6784fc8fff2 8048179: Early reclaim of large objects that are referenced by a few objects
tschatzl
parents: 27151
diff changeset
    61
    output.shouldContain("Dead humongous region");
27151
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    62
    output.shouldHaveExitValue(0);
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    63
  }
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    64
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    65
  static class GCWithHumongousObjectTest {
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    66
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    67
    public static final int M = 1024*1024;
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    68
    public static LinkedList<Object> garbageList = new LinkedList<Object>();
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    69
    // A large object referenced by a static.
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    70
    static int[] filler = new int[10 * M];
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    71
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    72
    public static void genGarbage() {
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    73
      for (int i = 0; i < 32*1024; i++) {
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    74
        garbageList.add(new int[100]);
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    75
      }
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    76
      garbageList.clear();
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    77
    }
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    78
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    79
    public static void main(String[] args) {
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    80
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    81
      int[] large = new int[M];
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    82
      Object ref = large;
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    83
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    84
      System.out.println("Creating garbage");
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    85
      for (int i = 0; i < 100; i++) {
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    86
        // A large object that will be reclaimed eagerly.
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    87
        large = new int[6*M];
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    88
        genGarbage();
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    89
        // Make sure that the compiler cannot completely remove
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    90
        // the allocation of the large object until here.
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    91
        System.out.println(large);
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    92
      }
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    93
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    94
      // Keep the reference to the first object alive.
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    95
      System.out.println(ref);
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    96
      System.out.println("Done");
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    97
    }
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    98
  }
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    99
}