15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test TestPLABPromotion
26 * @bug 8141278 8141141
27 * @summary Test PLAB promotion
28 * @requires vm.gc.G1
29 * @requires vm.flagless
30 * @library /test/lib /
31 * @modules java.base/jdk.internal.misc
32 * @modules java.management
33 * @build jdk.test.whitebox.WhiteBox
34 * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
35 * @run main/timeout=240 gc.g1.plab.TestPLABPromotion
36 */
37 package gc.g1.plab;
38
39 import java.util.List;
40 import java.util.Arrays;
41 import java.io.PrintStream;
42
43 import gc.g1.plab.lib.AppPLABPromotion;
44 import gc.g1.plab.lib.LogParser;
45 import gc.g1.plab.lib.PLABUtils;
46 import gc.g1.plab.lib.PlabInfo;
47
48 import jdk.test.lib.process.OutputAnalyzer;
49 import jdk.test.lib.process.ProcessTools;
50
51 /**
52 * Test checks PLAB promotion of different size objects.
53 */
54 public class TestPLABPromotion {
55
56 // GC ID with survivor PLAB statistics
57 private final static long GC_ID_SURVIVOR_STATS = 1l;
58 // GC ID with old PLAB statistics
59 private final static long GC_ID_OLD_STATS = 2l;
60
61 private final static String PLAB_USED_FIELD_NAME = "used";
62 private final static String PLAB_DIRECT_ALLOCATED_FIELD_NAME = "direct allocated";
63 private final static List<String> FIELDS_TO_EXTRACT = Arrays.asList(PLAB_USED_FIELD_NAME, PLAB_DIRECT_ALLOCATED_FIELD_NAME);
64
65 private static String output;
66
67 // Allowable difference for memory consumption (percentage)
68 private final static long MEM_DIFFERENCE_PCT = 5;
69
70 private static final int PLAB_SIZE_SMALL = 1024;
71 private static final int PLAB_SIZE_MEDIUM = 4096;
72 private static final int PLAB_SIZE_HIGH = 65536;
73 private static final int OBJECT_SIZE_SMALL = 10;
74 private static final int OBJECT_SIZE_MEDIUM = 100;
75 private static final int OBJECT_SIZE_HIGH = 3250;
76 private static final int GC_NUM_SMALL = 1;
77 private static final int GC_NUM_MEDIUM = 3;
78 private static final int GC_NUM_HIGH = 7;
79 private static final int WASTE_PCT_SMALL = 10;
80 private static final int WASTE_PCT_MEDIUM = 20;
81 private static final int WASTE_PCT_HIGH = 30;
82 private static final int YOUNG_SIZE_LOW = 16;
83 private static final int YOUNG_SIZE_HIGH = 64;
84 private static final boolean PLAB_FIXED = true;
85 private static final boolean PLAB_DYNAMIC = false;
86
87 private final static TestCase[] TEST_CASES = {
88 // Test cases for unreachable object, PLAB size is fixed
89 new TestCase(WASTE_PCT_SMALL, PLAB_SIZE_SMALL, OBJECT_SIZE_MEDIUM, GC_NUM_SMALL, YOUNG_SIZE_LOW, PLAB_FIXED, false, false),
90 new TestCase(WASTE_PCT_HIGH, PLAB_SIZE_MEDIUM, OBJECT_SIZE_SMALL, GC_NUM_HIGH, YOUNG_SIZE_HIGH, PLAB_FIXED, false, false),
91 // Test cases for reachable objects, PLAB size is fixed
92 new TestCase(WASTE_PCT_SMALL, PLAB_SIZE_SMALL, OBJECT_SIZE_SMALL, GC_NUM_HIGH, YOUNG_SIZE_HIGH, PLAB_FIXED, true, true),
93 new TestCase(WASTE_PCT_SMALL, PLAB_SIZE_MEDIUM, OBJECT_SIZE_MEDIUM, GC_NUM_SMALL, YOUNG_SIZE_LOW, PLAB_FIXED, true, true),
94 new TestCase(WASTE_PCT_SMALL, PLAB_SIZE_SMALL, OBJECT_SIZE_HIGH, GC_NUM_MEDIUM, YOUNG_SIZE_LOW, PLAB_FIXED, true, false),
95 new TestCase(WASTE_PCT_MEDIUM, PLAB_SIZE_HIGH, OBJECT_SIZE_SMALL, GC_NUM_HIGH, YOUNG_SIZE_HIGH, PLAB_FIXED, true, true),
|
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test TestPLABPromotion
26 * @bug 8141278 8141141
27 * @summary Test PLAB promotion
28 * @requires vm.gc.G1
29 * @requires vm.flagless
30 * @library /test/lib /
31 * @modules java.base/jdk.internal.misc
32 * @modules java.management
33 * @build jdk.test.whitebox.WhiteBox
34 * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
35 * @run main/othervm/timeout=240 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI gc.g1.plab.TestPLABPromotion
36 */
37 package gc.g1.plab;
38
39 import java.util.List;
40 import java.util.Arrays;
41 import java.io.PrintStream;
42
43 import gc.g1.plab.lib.AppPLABPromotion;
44 import gc.g1.plab.lib.LogParser;
45 import gc.g1.plab.lib.PLABUtils;
46 import gc.g1.plab.lib.PlabInfo;
47
48 import jdk.test.lib.Platform;
49 import jdk.test.lib.process.OutputAnalyzer;
50 import jdk.test.lib.process.ProcessTools;
51 import jdk.test.whitebox.WhiteBox;
52
53 /**
54 * Test checks PLAB promotion of different size objects.
55 */
56 public class TestPLABPromotion {
57
58 private static final boolean COMPACT_HEADERS = Platform.is64bit() && WhiteBox.getWhiteBox().getBooleanVMFlag("UseCompactObjectHeaders");
59
60 // GC ID with survivor PLAB statistics
61 private final static long GC_ID_SURVIVOR_STATS = 1l;
62 // GC ID with old PLAB statistics
63 private final static long GC_ID_OLD_STATS = 2l;
64
65 private final static String PLAB_USED_FIELD_NAME = "used";
66 private final static String PLAB_DIRECT_ALLOCATED_FIELD_NAME = "direct allocated";
67 private final static List<String> FIELDS_TO_EXTRACT = Arrays.asList(PLAB_USED_FIELD_NAME, PLAB_DIRECT_ALLOCATED_FIELD_NAME);
68
69 private static String output;
70
71 // Allowable difference for memory consumption (percentage)
72 private final static long MEM_DIFFERENCE_PCT = 5;
73
74 private static final int PLAB_SIZE_SMALL = 1024;
75 private static final int PLAB_SIZE_MEDIUM = 4096;
76 private static final int PLAB_SIZE_HIGH = 65536;
77 private static final int OBJECT_SIZE_SMALL = 10;
78 private static final int OBJECT_SIZE_MEDIUM = 100;
79 private static final int OBJECT_SIZE_HIGH = COMPACT_HEADERS ? 3266 : 3250;
80 private static final int GC_NUM_SMALL = 1;
81 private static final int GC_NUM_MEDIUM = 3;
82 private static final int GC_NUM_HIGH = 7;
83 private static final int WASTE_PCT_SMALL = 10;
84 private static final int WASTE_PCT_MEDIUM = 20;
85 private static final int WASTE_PCT_HIGH = 30;
86 private static final int YOUNG_SIZE_LOW = 16;
87 private static final int YOUNG_SIZE_HIGH = 64;
88 private static final boolean PLAB_FIXED = true;
89 private static final boolean PLAB_DYNAMIC = false;
90
91 private final static TestCase[] TEST_CASES = {
92 // Test cases for unreachable object, PLAB size is fixed
93 new TestCase(WASTE_PCT_SMALL, PLAB_SIZE_SMALL, OBJECT_SIZE_MEDIUM, GC_NUM_SMALL, YOUNG_SIZE_LOW, PLAB_FIXED, false, false),
94 new TestCase(WASTE_PCT_HIGH, PLAB_SIZE_MEDIUM, OBJECT_SIZE_SMALL, GC_NUM_HIGH, YOUNG_SIZE_HIGH, PLAB_FIXED, false, false),
95 // Test cases for reachable objects, PLAB size is fixed
96 new TestCase(WASTE_PCT_SMALL, PLAB_SIZE_SMALL, OBJECT_SIZE_SMALL, GC_NUM_HIGH, YOUNG_SIZE_HIGH, PLAB_FIXED, true, true),
97 new TestCase(WASTE_PCT_SMALL, PLAB_SIZE_MEDIUM, OBJECT_SIZE_MEDIUM, GC_NUM_SMALL, YOUNG_SIZE_LOW, PLAB_FIXED, true, true),
98 new TestCase(WASTE_PCT_SMALL, PLAB_SIZE_SMALL, OBJECT_SIZE_HIGH, GC_NUM_MEDIUM, YOUNG_SIZE_LOW, PLAB_FIXED, true, false),
99 new TestCase(WASTE_PCT_MEDIUM, PLAB_SIZE_HIGH, OBJECT_SIZE_SMALL, GC_NUM_HIGH, YOUNG_SIZE_HIGH, PLAB_FIXED, true, true),
|