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.Platform;
49 import jdk.test.lib.process.OutputAnalyzer;
50 import jdk.test.lib.process.ProcessTools;
51
52 /**
53 * Test checks PLAB promotion of different size objects.
54 */
55 public class TestPLABPromotion {
56
57 // GC ID with survivor PLAB statistics
58 private final static long GC_ID_SURVIVOR_STATS = 1l;
59 // GC ID with old PLAB statistics
60 private final static long GC_ID_OLD_STATS = 2l;
61
62 private final static String PLAB_USED_FIELD_NAME = "used";
63 private final static String PLAB_DIRECT_ALLOCATED_FIELD_NAME = "direct allocated";
64 private final static List<String> FIELDS_TO_EXTRACT = Arrays.asList(PLAB_USED_FIELD_NAME, PLAB_DIRECT_ALLOCATED_FIELD_NAME);
65
66 private static final int HEAP_WORD_SIZE = Platform.is32bit() ? 4 : 8;
67
68 private static String output;
69
70 // Allowable difference for memory consumption (percentage)
71 private final static long MEM_DIFFERENCE_PCT = 5;
72 private static final int PLAB_SIZE_SMALL = 1024;
73 private static final int PLAB_SIZE_MEDIUM = 4096;
74 private static final int PLAB_SIZE_HIGH = 65536;
75 private static final int OBJECT_SIZE_SMALL = 10 * HEAP_WORD_SIZE;
76 private static final int OBJECT_SIZE_MEDIUM = 128 * HEAP_WORD_SIZE;
77 private static final int OBJECT_SIZE_HIGH = 3072 * HEAP_WORD_SIZE;
78 private static final int GC_NUM_SMALL = 1;
79 private static final int GC_NUM_MEDIUM = 3;
80 private static final int GC_NUM_HIGH = 7;
81 private static final int WASTE_PCT_SMALL = 10;
82 private static final int WASTE_PCT_MEDIUM = 20;
83 private static final int WASTE_PCT_HIGH = 30;
84 private static final int YOUNG_SIZE_LOW = 16;
85 private static final int YOUNG_SIZE_HIGH = 64;
86 private static final boolean PLAB_FIXED = true;
87 private static final boolean PLAB_DYNAMIC = false;
88
89 private final static TestCase[] TEST_CASES = {
90 // Test cases for unreachable object, PLAB size is fixed
91 new TestCase(WASTE_PCT_SMALL, PLAB_SIZE_SMALL, OBJECT_SIZE_MEDIUM, GC_NUM_SMALL, YOUNG_SIZE_LOW, PLAB_FIXED, false, false),
92 new TestCase(WASTE_PCT_HIGH, PLAB_SIZE_MEDIUM, OBJECT_SIZE_SMALL, GC_NUM_HIGH, YOUNG_SIZE_HIGH, PLAB_FIXED, false, false),
93 // Test cases for reachable objects, PLAB size is fixed
94 new TestCase(WASTE_PCT_SMALL, PLAB_SIZE_SMALL, OBJECT_SIZE_SMALL, GC_NUM_HIGH, YOUNG_SIZE_HIGH, PLAB_FIXED, true, true),
95 new TestCase(WASTE_PCT_SMALL, PLAB_SIZE_MEDIUM, OBJECT_SIZE_MEDIUM, GC_NUM_SMALL, YOUNG_SIZE_LOW, PLAB_FIXED, true, true),
96 new TestCase(WASTE_PCT_SMALL, PLAB_SIZE_SMALL, OBJECT_SIZE_HIGH, GC_NUM_MEDIUM, YOUNG_SIZE_LOW, PLAB_FIXED, true, false),
97 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 final int HEAP_WORD_SIZE = Platform.is32bit() ? 4 : 8;
70
71 private static String output;
72
73 // Allowable difference for memory consumption (percentage)
74 private final static long MEM_DIFFERENCE_PCT = 5;
75 private static final int PLAB_SIZE_SMALL = 1024;
76 private static final int PLAB_SIZE_MEDIUM = 4096;
77 private static final int PLAB_SIZE_HIGH = 65536;
78 private static final int OBJECT_SIZE_SMALL = 10 * HEAP_WORD_SIZE;
79 private static final int OBJECT_SIZE_MEDIUM = 128 * HEAP_WORD_SIZE;
80 private static final int OBJECT_SIZE_HIGH = (COMPACT_HEADERS ? 3266 : 3250) * HEAP_WORD_SIZE;
81 private static final int GC_NUM_SMALL = 1;
82 private static final int GC_NUM_MEDIUM = 3;
83 private static final int GC_NUM_HIGH = 7;
84 private static final int WASTE_PCT_SMALL = 10;
85 private static final int WASTE_PCT_MEDIUM = 20;
86 private static final int WASTE_PCT_HIGH = 30;
87 private static final int YOUNG_SIZE_LOW = 16;
88 private static final int YOUNG_SIZE_HIGH = 64;
89 private static final boolean PLAB_FIXED = true;
90 private static final boolean PLAB_DYNAMIC = false;
91
92 private final static TestCase[] TEST_CASES = {
93 // Test cases for unreachable object, PLAB size is fixed
94 new TestCase(WASTE_PCT_SMALL, PLAB_SIZE_SMALL, OBJECT_SIZE_MEDIUM, GC_NUM_SMALL, YOUNG_SIZE_LOW, PLAB_FIXED, false, false),
95 new TestCase(WASTE_PCT_HIGH, PLAB_SIZE_MEDIUM, OBJECT_SIZE_SMALL, GC_NUM_HIGH, YOUNG_SIZE_HIGH, PLAB_FIXED, false, false),
96 // Test cases for reachable objects, PLAB size is fixed
97 new TestCase(WASTE_PCT_SMALL, PLAB_SIZE_SMALL, OBJECT_SIZE_SMALL, GC_NUM_HIGH, YOUNG_SIZE_HIGH, PLAB_FIXED, true, true),
98 new TestCase(WASTE_PCT_SMALL, PLAB_SIZE_MEDIUM, OBJECT_SIZE_MEDIUM, GC_NUM_SMALL, YOUNG_SIZE_LOW, PLAB_FIXED, true, true),
99 new TestCase(WASTE_PCT_SMALL, PLAB_SIZE_SMALL, OBJECT_SIZE_HIGH, GC_NUM_MEDIUM, YOUNG_SIZE_LOW, PLAB_FIXED, true, false),
100 new TestCase(WASTE_PCT_MEDIUM, PLAB_SIZE_HIGH, OBJECT_SIZE_SMALL, GC_NUM_HIGH, YOUNG_SIZE_HIGH, PLAB_FIXED, true, true),
|