hotspot/test/gc/g1/plab/TestPLABPromotion.java
author sla
Wed, 09 Mar 2016 12:30:39 +0100
changeset 37047 ba4d0448cc09
parent 36390 a2d991d1d628
child 37181 0d5e8ae18924
permissions -rw-r--r--
8151196: Several tests fail due to test library not found Reviewed-by: ctornqvi, brutisso
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35885
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
     1
/*
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
     4
 *
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
     7
 * published by the Free Software Foundation.
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
     8
 *
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    13
 * accompanied this code).
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    14
 *
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    18
 *
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    21
 * questions.
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    22
 */
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    23
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    24
 /*
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    25
 * @test TestPLABPromotion
36390
a2d991d1d628 8141141: Young and Old gen PLAB stats are similar in output with -XX:+PrintPLAB
tschatzl
parents: 35947
diff changeset
    26
 * @bug 8141278 8141141
35885
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    27
 * @summary Test PLAB promotion
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    28
 * @requires vm.gc=="G1" | vm.gc=="null"
35947
48c797584ac2 8148745: [testbug] Test gc/g1/plab/TestPLABPromotion.java fails in nightly
mchernov
parents: 35885
diff changeset
    29
 * @requires vm.opt.FlightRecorder != true
37047
ba4d0448cc09 8151196: Several tests fail due to test library not found
sla
parents: 36390
diff changeset
    30
 * @library /testlibrary /test/lib /
35885
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    31
 * @modules java.management
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    32
 * @build ClassFileInstaller
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    33
 *        sun.hotspot.WhiteBox
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    34
 *        gc.g1.plab.lib.MemoryConsumer
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    35
 *        gc.g1.plab.lib.LogParser
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    36
 *        gc.g1.plab.lib.AppPLABPromotion
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    37
 * @run main ClassFileInstaller sun.hotspot.WhiteBox
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    38
 *                              sun.hotspot.WhiteBox$WhiteBoxPermission
35947
48c797584ac2 8148745: [testbug] Test gc/g1/plab/TestPLABPromotion.java fails in nightly
mchernov
parents: 35885
diff changeset
    39
 * @run main/timeout=240 gc.g1.plab.TestPLABPromotion
35885
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    40
 */
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    41
package gc.g1.plab;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    42
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    43
import java.util.List;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    44
import java.util.Map;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    45
import java.util.Arrays;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    46
import java.io.PrintStream;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    47
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    48
import gc.g1.plab.lib.AppPLABPromotion;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    49
import gc.g1.plab.lib.LogParser;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    50
import gc.g1.plab.lib.PLABUtils;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    51
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    52
import jdk.test.lib.OutputAnalyzer;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    53
import jdk.test.lib.ProcessTools;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    54
import jdk.test.lib.Platform;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    55
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    56
/**
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    57
 * Test checks PLAB promotion of different size objects.
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    58
 */
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    59
public class TestPLABPromotion {
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    60
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    61
    // GC ID with survivor PLAB statistics
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    62
    private final static long GC_ID_SURVIVOR_STATS = 1l;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    63
    // GC ID with old PLAB statistics
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    64
    private final static long GC_ID_OLD_STATS = 2l;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    65
35947
48c797584ac2 8148745: [testbug] Test gc/g1/plab/TestPLABPromotion.java fails in nightly
mchernov
parents: 35885
diff changeset
    66
    // Allowable difference for memory consumption (percentage)
48c797584ac2 8148745: [testbug] Test gc/g1/plab/TestPLABPromotion.java fails in nightly
mchernov
parents: 35885
diff changeset
    67
    private final static long MEM_DIFFERENCE_PCT = 5;
35885
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    68
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    69
    private static final int PLAB_SIZE_SMALL = 1024;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    70
    private static final int PLAB_SIZE_MEDIUM = 4096;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    71
    private static final int PLAB_SIZE_HIGH = 65536;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    72
    private static final int OBJECT_SIZE_SMALL = 10;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    73
    private static final int OBJECT_SIZE_MEDIUM = 100;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    74
    private static final int OBJECT_SIZE_HIGH = 1000;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    75
    private static final int GC_NUM_SMALL = 1;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    76
    private static final int GC_NUM_MEDIUM = 3;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    77
    private static final int GC_NUM_HIGH = 7;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    78
    private static final int WASTE_PCT_SMALL = 10;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    79
    private static final int WASTE_PCT_MEDIUM = 20;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    80
    private static final int WASTE_PCT_HIGH = 30;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    81
    private static final int YOUNG_SIZE_LOW = 16;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    82
    private static final int YOUNG_SIZE_HIGH = 64;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    83
    private static final boolean PLAB_FIXED = true;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    84
    private static final boolean PLAB_DYNAMIC = false;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    85
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    86
    private final static TestCase[] TEST_CASES = {
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    87
        // Test cases for unreachable object, PLAB size is fixed
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    88
        new TestCase(WASTE_PCT_SMALL, PLAB_SIZE_SMALL, OBJECT_SIZE_MEDIUM, GC_NUM_SMALL, YOUNG_SIZE_LOW, PLAB_FIXED, false, false),
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    89
        new TestCase(WASTE_PCT_HIGH, PLAB_SIZE_MEDIUM, OBJECT_SIZE_SMALL, GC_NUM_HIGH, YOUNG_SIZE_HIGH, PLAB_FIXED, false, false),
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    90
        // Test cases for reachable objects, PLAB size is fixed
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    91
        new TestCase(WASTE_PCT_SMALL, PLAB_SIZE_SMALL, OBJECT_SIZE_SMALL, GC_NUM_HIGH, YOUNG_SIZE_HIGH, PLAB_FIXED, true, true),
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    92
        new TestCase(WASTE_PCT_SMALL, PLAB_SIZE_MEDIUM, OBJECT_SIZE_MEDIUM, GC_NUM_SMALL, YOUNG_SIZE_LOW, PLAB_FIXED, true, true),
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    93
        new TestCase(WASTE_PCT_SMALL, PLAB_SIZE_SMALL, OBJECT_SIZE_HIGH, GC_NUM_MEDIUM, YOUNG_SIZE_LOW, PLAB_FIXED, true, false),
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    94
        new TestCase(WASTE_PCT_MEDIUM, PLAB_SIZE_HIGH, OBJECT_SIZE_SMALL, GC_NUM_HIGH, YOUNG_SIZE_HIGH, PLAB_FIXED, true, true),
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    95
        new TestCase(WASTE_PCT_MEDIUM, PLAB_SIZE_SMALL, OBJECT_SIZE_MEDIUM, GC_NUM_SMALL, YOUNG_SIZE_LOW, PLAB_FIXED, true, true),
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    96
        new TestCase(WASTE_PCT_MEDIUM, PLAB_SIZE_MEDIUM, OBJECT_SIZE_HIGH, GC_NUM_MEDIUM, YOUNG_SIZE_LOW, PLAB_FIXED, true, true),
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    97
        new TestCase(WASTE_PCT_HIGH, PLAB_SIZE_SMALL, OBJECT_SIZE_SMALL, GC_NUM_HIGH, YOUNG_SIZE_HIGH, PLAB_FIXED, true, true),
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    98
        new TestCase(WASTE_PCT_HIGH, PLAB_SIZE_HIGH, OBJECT_SIZE_MEDIUM, GC_NUM_SMALL, YOUNG_SIZE_LOW, PLAB_FIXED, true, true),
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
    99
        new TestCase(WASTE_PCT_HIGH, PLAB_SIZE_SMALL, OBJECT_SIZE_HIGH, GC_NUM_MEDIUM, YOUNG_SIZE_HIGH, PLAB_FIXED, true, false),
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   100
        // Test cases for unreachable object, PLAB size is not fixed
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   101
        new TestCase(WASTE_PCT_MEDIUM, PLAB_SIZE_MEDIUM, OBJECT_SIZE_SMALL, GC_NUM_HIGH, YOUNG_SIZE_LOW, PLAB_DYNAMIC, false, false),
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   102
        // Test cases for reachable objects, PLAB size is not fixed
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   103
        new TestCase(WASTE_PCT_SMALL, PLAB_SIZE_HIGH, OBJECT_SIZE_SMALL, GC_NUM_HIGH, YOUNG_SIZE_HIGH, PLAB_DYNAMIC, true, true),
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   104
        new TestCase(WASTE_PCT_MEDIUM, PLAB_SIZE_MEDIUM, OBJECT_SIZE_SMALL, GC_NUM_SMALL, YOUNG_SIZE_LOW, PLAB_DYNAMIC, true, true),
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   105
        new TestCase(WASTE_PCT_SMALL, PLAB_SIZE_MEDIUM, OBJECT_SIZE_HIGH, GC_NUM_HIGH, YOUNG_SIZE_HIGH, PLAB_DYNAMIC, true, false),
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   106
        new TestCase(WASTE_PCT_MEDIUM, PLAB_SIZE_SMALL, OBJECT_SIZE_MEDIUM, GC_NUM_MEDIUM, YOUNG_SIZE_LOW, PLAB_DYNAMIC, true, true),
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   107
        new TestCase(WASTE_PCT_HIGH, PLAB_SIZE_HIGH, OBJECT_SIZE_MEDIUM, GC_NUM_SMALL, YOUNG_SIZE_HIGH, PLAB_DYNAMIC, true, true),
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   108
        new TestCase(WASTE_PCT_HIGH, PLAB_SIZE_HIGH, OBJECT_SIZE_SMALL, GC_NUM_HIGH, YOUNG_SIZE_LOW, PLAB_DYNAMIC, true, true)
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   109
    };
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   110
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   111
    public static void main(String[] args) throws Throwable {
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   112
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   113
        for (TestCase testCase : TEST_CASES) {
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   114
            // What we going to check.
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   115
            testCase.print(System.out);
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   116
            List<String> options = PLABUtils.prepareOptions(testCase.toOptions());
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   117
            options.add(AppPLABPromotion.class.getName());
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   118
            OutputAnalyzer out = ProcessTools.executeTestJvm(options.toArray(new String[options.size()]));
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   119
            if (out.getExitValue() != 0) {
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   120
                System.out.println(out.getOutput());
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   121
                throw new RuntimeException("Expect exit code 0.");
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   122
            }
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   123
            checkResults(out.getOutput(), testCase);
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   124
        }
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   125
    }
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   126
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   127
    private static void checkResults(String output, TestCase testCase) {
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   128
        long plabAllocatedSurvivor;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   129
        long directAllocatedSurvivor;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   130
        long plabAllocatedOld;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   131
        long directAllocatedOld;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   132
        long memAllocated = testCase.getMemToFill();
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   133
        LogParser logParser = new LogParser(output);
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   134
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   135
        Map<String, Long> survivorStats = getPlabStats(logParser, LogParser.ReportType.SURVIVOR_STATS, GC_ID_SURVIVOR_STATS);
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   136
        Map<String, Long> oldStats = getPlabStats(logParser, LogParser.ReportType.OLD_STATS, GC_ID_OLD_STATS);
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   137
36390
a2d991d1d628 8141141: Young and Old gen PLAB stats are similar in output with -XX:+PrintPLAB
tschatzl
parents: 35947
diff changeset
   138
        plabAllocatedSurvivor = survivorStats.get("used");
a2d991d1d628 8141141: Young and Old gen PLAB stats are similar in output with -XX:+PrintPLAB
tschatzl
parents: 35947
diff changeset
   139
        directAllocatedSurvivor = survivorStats.get("direct allocated");
a2d991d1d628 8141141: Young and Old gen PLAB stats are similar in output with -XX:+PrintPLAB
tschatzl
parents: 35947
diff changeset
   140
        plabAllocatedOld = oldStats.get("used");
a2d991d1d628 8141141: Young and Old gen PLAB stats are similar in output with -XX:+PrintPLAB
tschatzl
parents: 35947
diff changeset
   141
        directAllocatedOld = oldStats.get("direct allocated");
35885
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   142
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   143
        System.out.printf("Survivor PLAB allocated:%17d Direct allocated: %17d Mem consumed:%17d%n", plabAllocatedSurvivor, directAllocatedSurvivor, memAllocated);
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   144
        System.out.printf("Old      PLAB allocated:%17d Direct allocated: %17d Mem consumed:%17d%n", plabAllocatedOld, directAllocatedOld, memAllocated);
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   145
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   146
        // Unreachable objects case
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   147
        if (testCase.isDeadObjectCase()) {
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   148
            // No dead objects should be promoted
35947
48c797584ac2 8148745: [testbug] Test gc/g1/plab/TestPLABPromotion.java fails in nightly
mchernov
parents: 35885
diff changeset
   149
            if (!(checkRatio(plabAllocatedSurvivor, memAllocated) && checkRatio(directAllocatedSurvivor, memAllocated))) {
35885
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   150
                System.out.println(output);
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   151
                throw new RuntimeException("Unreachable objects should not be allocated using PLAB or direct allocated to Survivor");
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   152
            }
35947
48c797584ac2 8148745: [testbug] Test gc/g1/plab/TestPLABPromotion.java fails in nightly
mchernov
parents: 35885
diff changeset
   153
            if (!(checkRatio(plabAllocatedOld, memAllocated) && checkRatio(directAllocatedOld, memAllocated))) {
35885
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   154
                System.out.println(output);
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   155
                throw new RuntimeException("Unreachable objects should not be allocated using PLAB or direct allocated to Old");
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   156
            }
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   157
        } else {
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   158
            // Live objects case
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   159
            if (testCase.isPromotedByPLAB()) {
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   160
                // All live small objects should be promoted using PLAB
35947
48c797584ac2 8148745: [testbug] Test gc/g1/plab/TestPLABPromotion.java fails in nightly
mchernov
parents: 35885
diff changeset
   161
                if (!checkDifferenceRatio(plabAllocatedSurvivor, memAllocated)) {
35885
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   162
                    System.out.println(output);
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   163
                    throw new RuntimeException("Expect that Survivor PLAB allocation are similar to all mem consumed");
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   164
                }
35947
48c797584ac2 8148745: [testbug] Test gc/g1/plab/TestPLABPromotion.java fails in nightly
mchernov
parents: 35885
diff changeset
   165
                if (!checkDifferenceRatio(plabAllocatedOld, memAllocated)) {
35885
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   166
                    System.out.println(output);
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   167
                    throw new RuntimeException("Expect that Old PLAB allocation are similar to all mem consumed");
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   168
                }
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   169
            } else {
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   170
                // All big objects should be directly allocated
35947
48c797584ac2 8148745: [testbug] Test gc/g1/plab/TestPLABPromotion.java fails in nightly
mchernov
parents: 35885
diff changeset
   171
                if (!checkDifferenceRatio(directAllocatedSurvivor, memAllocated)) {
35885
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   172
                    System.out.println(output);
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   173
                    throw new RuntimeException("Test fails. Expect that Survivor direct allocation are similar to all mem consumed");
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   174
                }
35947
48c797584ac2 8148745: [testbug] Test gc/g1/plab/TestPLABPromotion.java fails in nightly
mchernov
parents: 35885
diff changeset
   175
                if (!checkDifferenceRatio(directAllocatedOld, memAllocated)) {
35885
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   176
                    System.out.println(output);
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   177
                    throw new RuntimeException("Test fails. Expect that Old direct allocation are similar to all mem consumed");
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   178
                }
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   179
            }
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   180
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   181
            // All promoted objects size should be similar to all consumed memory
35947
48c797584ac2 8148745: [testbug] Test gc/g1/plab/TestPLABPromotion.java fails in nightly
mchernov
parents: 35885
diff changeset
   182
            if (!checkDifferenceRatio(plabAllocatedSurvivor + directAllocatedSurvivor, memAllocated)) {
35885
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   183
                System.out.println(output);
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   184
                throw new RuntimeException("Test fails. Expect that Survivor gen total allocation are similar to all mem consumed");
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   185
            }
35947
48c797584ac2 8148745: [testbug] Test gc/g1/plab/TestPLABPromotion.java fails in nightly
mchernov
parents: 35885
diff changeset
   186
            if (!checkDifferenceRatio(plabAllocatedOld + directAllocatedOld, memAllocated)) {
35885
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   187
                System.out.println(output);
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   188
                throw new RuntimeException("Test fails. Expect that Old gen total allocation are similar to all mem consumed");
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   189
            }
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   190
        }
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   191
        System.out.println("Test passed!");
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   192
    }
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   193
35947
48c797584ac2 8148745: [testbug] Test gc/g1/plab/TestPLABPromotion.java fails in nightly
mchernov
parents: 35885
diff changeset
   194
    /**
48c797584ac2 8148745: [testbug] Test gc/g1/plab/TestPLABPromotion.java fails in nightly
mchernov
parents: 35885
diff changeset
   195
     * Returns true if checkedValue is less than MEM_DIFFERENCE_PCT percent of controlValue.
48c797584ac2 8148745: [testbug] Test gc/g1/plab/TestPLABPromotion.java fails in nightly
mchernov
parents: 35885
diff changeset
   196
     *
48c797584ac2 8148745: [testbug] Test gc/g1/plab/TestPLABPromotion.java fails in nightly
mchernov
parents: 35885
diff changeset
   197
     * @param checkedValue - checked value
48c797584ac2 8148745: [testbug] Test gc/g1/plab/TestPLABPromotion.java fails in nightly
mchernov
parents: 35885
diff changeset
   198
     * @param controlValue - referent value
48c797584ac2 8148745: [testbug] Test gc/g1/plab/TestPLABPromotion.java fails in nightly
mchernov
parents: 35885
diff changeset
   199
     * @return true if checkedValue is less than MEM_DIFFERENCE_PCT percent of controlValue
48c797584ac2 8148745: [testbug] Test gc/g1/plab/TestPLABPromotion.java fails in nightly
mchernov
parents: 35885
diff changeset
   200
     */
48c797584ac2 8148745: [testbug] Test gc/g1/plab/TestPLABPromotion.java fails in nightly
mchernov
parents: 35885
diff changeset
   201
    private static boolean checkRatio(long checkedValue, long controlValue) {
48c797584ac2 8148745: [testbug] Test gc/g1/plab/TestPLABPromotion.java fails in nightly
mchernov
parents: 35885
diff changeset
   202
        return (Math.abs(checkedValue) / controlValue) * 100L < MEM_DIFFERENCE_PCT;
48c797584ac2 8148745: [testbug] Test gc/g1/plab/TestPLABPromotion.java fails in nightly
mchernov
parents: 35885
diff changeset
   203
    }
48c797584ac2 8148745: [testbug] Test gc/g1/plab/TestPLABPromotion.java fails in nightly
mchernov
parents: 35885
diff changeset
   204
48c797584ac2 8148745: [testbug] Test gc/g1/plab/TestPLABPromotion.java fails in nightly
mchernov
parents: 35885
diff changeset
   205
    /**
48c797584ac2 8148745: [testbug] Test gc/g1/plab/TestPLABPromotion.java fails in nightly
mchernov
parents: 35885
diff changeset
   206
     * Returns true if difference of checkedValue and controlValue is less than
48c797584ac2 8148745: [testbug] Test gc/g1/plab/TestPLABPromotion.java fails in nightly
mchernov
parents: 35885
diff changeset
   207
     * MEM_DIFFERENCE_PCT percent of controlValue.
48c797584ac2 8148745: [testbug] Test gc/g1/plab/TestPLABPromotion.java fails in nightly
mchernov
parents: 35885
diff changeset
   208
     *
48c797584ac2 8148745: [testbug] Test gc/g1/plab/TestPLABPromotion.java fails in nightly
mchernov
parents: 35885
diff changeset
   209
     * @param checkedValue - checked value
48c797584ac2 8148745: [testbug] Test gc/g1/plab/TestPLABPromotion.java fails in nightly
mchernov
parents: 35885
diff changeset
   210
     * @param controlValue - referent value
48c797584ac2 8148745: [testbug] Test gc/g1/plab/TestPLABPromotion.java fails in nightly
mchernov
parents: 35885
diff changeset
   211
     * @return true if difference of checkedValue and controlValue is less than
48c797584ac2 8148745: [testbug] Test gc/g1/plab/TestPLABPromotion.java fails in nightly
mchernov
parents: 35885
diff changeset
   212
     * MEM_DIFFERENCE_PCT percent of controlValue
48c797584ac2 8148745: [testbug] Test gc/g1/plab/TestPLABPromotion.java fails in nightly
mchernov
parents: 35885
diff changeset
   213
     */
48c797584ac2 8148745: [testbug] Test gc/g1/plab/TestPLABPromotion.java fails in nightly
mchernov
parents: 35885
diff changeset
   214
    private static boolean checkDifferenceRatio(long checkedValue, long controlValue) {
48c797584ac2 8148745: [testbug] Test gc/g1/plab/TestPLABPromotion.java fails in nightly
mchernov
parents: 35885
diff changeset
   215
        return (Math.abs(checkedValue - controlValue) / controlValue) * 100L < MEM_DIFFERENCE_PCT;
48c797584ac2 8148745: [testbug] Test gc/g1/plab/TestPLABPromotion.java fails in nightly
mchernov
parents: 35885
diff changeset
   216
    }
48c797584ac2 8148745: [testbug] Test gc/g1/plab/TestPLABPromotion.java fails in nightly
mchernov
parents: 35885
diff changeset
   217
35885
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   218
    private static Map<String, Long> getPlabStats(LogParser logParser, LogParser.ReportType type, long gc_id) {
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   219
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   220
        Map<String, Long> survivorStats = logParser.getEntries()
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   221
                .get(gc_id)
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   222
                .get(type);
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   223
        return survivorStats;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   224
    }
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   225
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   226
    /**
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   227
     * Description of one test case.
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   228
     */
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   229
    private static class TestCase {
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   230
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   231
        private final int wastePct;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   232
        private final int plabSize;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   233
        private final int chunkSize;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   234
        private final int parGCThreads;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   235
        private final int edenSize;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   236
        private final boolean plabIsFixed;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   237
        private final boolean objectsAreReachable;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   238
        private final boolean promotedByPLAB;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   239
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   240
        /**
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   241
         * @param wastePct
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   242
         * ParallelGCBufferWastePct
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   243
         * @param plabSize
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   244
         * -XX:OldPLABSize and -XX:YoungPLABSize
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   245
         * @param chunkSize
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   246
         * requested object size for memory consumption
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   247
         * @param parGCThreads
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   248
         * -XX:ParallelGCThreads
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   249
         * @param edenSize
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   250
         * NewSize and MaxNewSize
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   251
         * @param plabIsFixed
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   252
         * Use dynamic PLAB or fixed size PLAB
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   253
         * @param objectsAreReachable
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   254
         * true - allocate live objects
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   255
         * false - allocate unreachable objects
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   256
         * @param promotedByPLAB
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   257
         * true - we expect to see PLAB allocation during promotion
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   258
         * false - objects will be directly allocated during promotion
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   259
         */
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   260
        public TestCase(int wastePct,
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   261
                int plabSize,
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   262
                int chunkSize,
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   263
                int parGCThreads,
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   264
                int edenSize,
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   265
                boolean plabIsFixed,
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   266
                boolean objectsAreReachable,
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   267
                boolean promotedByPLAB
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   268
        ) {
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   269
            if (wastePct == 0 || plabSize == 0 || chunkSize == 0 || parGCThreads == 0 || edenSize == 0) {
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   270
                throw new IllegalArgumentException("Parameters should not be 0");
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   271
            }
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   272
            this.wastePct = wastePct;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   273
            this.plabSize = plabSize;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   274
            this.chunkSize = chunkSize;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   275
            this.parGCThreads = parGCThreads;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   276
            this.edenSize = edenSize;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   277
            this.plabIsFixed = plabIsFixed;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   278
            this.objectsAreReachable = objectsAreReachable;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   279
            this.promotedByPLAB = promotedByPLAB;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   280
        }
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   281
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   282
        /**
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   283
         * Convert current TestCase to List of options.
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   284
         * Assume test will fill half of existed eden.
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   285
         *
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   286
         * @return
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   287
         * List of options
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   288
         */
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   289
        public List<String> toOptions() {
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   290
            return Arrays.asList("-XX:ParallelGCThreads=" + parGCThreads,
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   291
                    "-XX:ParallelGCBufferWastePct=" + wastePct,
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   292
                    "-XX:OldPLABSize=" + plabSize,
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   293
                    "-XX:YoungPLABSize=" + plabSize,
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   294
                    "-XX:" + (plabIsFixed ? "-" : "+") + "ResizePLAB",
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   295
                    "-Dchunk.size=" + chunkSize,
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   296
                    "-Dreachable=" + objectsAreReachable,
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   297
                    "-XX:NewSize=" + edenSize + "m",
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   298
                    "-XX:MaxNewSize=" + edenSize + "m",
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   299
                    "-Dmem.to.fill=" + getMemToFill()
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   300
            );
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   301
        }
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   302
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   303
        /**
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   304
         * Print details about test case.
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   305
         */
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   306
        public void print(PrintStream out) {
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   307
            boolean expectPLABAllocation = promotedByPLAB && objectsAreReachable;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   308
            boolean expectDirectAllocation = (!promotedByPLAB) && objectsAreReachable;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   309
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   310
            out.println("Test case details:");
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   311
            out.println("  Young gen size : " + edenSize + "M");
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   312
            out.println("  Predefined PLAB size : " + plabSize);
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   313
            out.println("  Parallel GC buffer waste pct : " + wastePct);
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   314
            out.println("  Chunk size : " + chunkSize);
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   315
            out.println("  Parallel GC threads : " + parGCThreads);
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   316
            out.println("  Objects are created : " + (objectsAreReachable ? "reachable" : "unreachable"));
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   317
            out.println("  PLAB size is fixed: " + (plabIsFixed ? "yes" : "no"));
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   318
            out.println("Test expectations:");
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   319
            out.println("  PLAB allocation : " + (expectPLABAllocation ? "expected" : "unexpected"));
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   320
            out.println("  Direct allocation : " + (expectDirectAllocation ? "expected" : "unexpected"));
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   321
        }
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   322
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   323
        /**
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   324
         * @return
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   325
         * true if we expect PLAB allocation
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   326
         * false if no
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   327
         */
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   328
        public boolean isPromotedByPLAB() {
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   329
            return promotedByPLAB;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   330
        }
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   331
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   332
        /**
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   333
         * @return
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   334
         * true if it is test case for unreachable objects
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   335
         * false for live objects
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   336
         */
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   337
        public boolean isDeadObjectCase() {
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   338
            return !objectsAreReachable;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   339
        }
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   340
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   341
        /**
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   342
         * Returns amount of memory to fill
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   343
         *
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   344
         * @return amount of memory
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   345
         */
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   346
        public long getMemToFill() {
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   347
            return (long) (edenSize) * 1024l * 1024l / 2;
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   348
        }
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   349
    }
6e62be7db2c8 8141278: New tests for PLAB testing
mchernov
parents:
diff changeset
   350
}