48 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:.
49 * -XX:+UseTLAB -XX:TLABSize=100k -XX:-ResizeTLAB -XX:TLABRefillWasteFraction=1
50 * -Xint
51 * jdk.jfr.event.allocation.TestObjectAllocationInNewTLABEvent
52 */
53
54 /**
55 * Test that when an object is allocated in a new Thread Local Allocation Buffer (TLAB)
56 * an event will be triggered. The test is done for default and interpreted mode (-Xint).
57 *
58 * To force objects to be allocated in a new TLAB:
59 * the initial size of TLAB is set to 100k (-XX:TLABSize=100k);
60 * the size of allocated objects is set to 128k;
61 * max TLAB waste at refill is set to minimum (-XX:TLABRefillWasteFraction=1),
62 * to provoke a new TLAB creation.
63 */
64 public class TestObjectAllocationInNewTLABEvent {
65 private final static String EVENT_NAME = EventNames.ObjectAllocationInNewTLAB;
66
67 private static final Boolean COMPRESSED_CLASS_PTRS = WhiteBox.getWhiteBox().getBooleanVMFlag("UseCompressedClassPointers");
68
69 private static final int BYTE_ARRAY_OVERHEAD = (Platform.is64bit() && !COMPRESSED_CLASS_PTRS) ? 24 : 16;
70 private static final int OBJECT_SIZE = 128 * 1024;
71
72 private static final int OBJECTS_TO_ALLOCATE = 100;
73 private static final String BYTE_ARRAY_CLASS_NAME = new byte[0].getClass().getName();
74 private static final int INITIAL_TLAB_SIZE = 100 * 1024;
75 private static int countAllTlabs; // Count all matching tlab allocations.
76 private static int countFullTlabs; // Count matching tlab allocations with full tlab size.
77
78 // Make sure allocation isn't dead code eliminated.
79 public static byte[] tmp;
80
81 public static void main(String[] args) throws Exception {
82 Recording recording = new Recording();
83 recording.enable(EVENT_NAME);
84 recording.start();
85 System.gc();
86 allocate();
87 recording.stop();
88 verifyRecording(recording);
89 int minCount = (int) floor(OBJECTS_TO_ALLOCATE * 0.80);
|
48 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:.
49 * -XX:+UseTLAB -XX:TLABSize=100k -XX:-ResizeTLAB -XX:TLABRefillWasteFraction=1
50 * -Xint
51 * jdk.jfr.event.allocation.TestObjectAllocationInNewTLABEvent
52 */
53
54 /**
55 * Test that when an object is allocated in a new Thread Local Allocation Buffer (TLAB)
56 * an event will be triggered. The test is done for default and interpreted mode (-Xint).
57 *
58 * To force objects to be allocated in a new TLAB:
59 * the initial size of TLAB is set to 100k (-XX:TLABSize=100k);
60 * the size of allocated objects is set to 128k;
61 * max TLAB waste at refill is set to minimum (-XX:TLABRefillWasteFraction=1),
62 * to provoke a new TLAB creation.
63 */
64 public class TestObjectAllocationInNewTLABEvent {
65 private final static String EVENT_NAME = EventNames.ObjectAllocationInNewTLAB;
66
67 private static final Boolean COMPRESSED_CLASS_PTRS = WhiteBox.getWhiteBox().getBooleanVMFlag("UseCompressedClassPointers");
68 private static final Boolean COMPACT_HEADERS = WhiteBox.getWhiteBox().getBooleanVMFlag("UseCompactObjectHeaders");
69
70 private static final int BYTE_ARRAY_OVERHEAD = COMPACT_HEADERS ? 12 : ((Platform.is64bit() && !COMPRESSED_CLASS_PTRS) ? 24 : 16);
71 private static final int OBJECT_SIZE = 128 * 1024;
72
73 private static final int OBJECTS_TO_ALLOCATE = 100;
74 private static final String BYTE_ARRAY_CLASS_NAME = new byte[0].getClass().getName();
75 private static final int INITIAL_TLAB_SIZE = 100 * 1024;
76 private static int countAllTlabs; // Count all matching tlab allocations.
77 private static int countFullTlabs; // Count matching tlab allocations with full tlab size.
78
79 // Make sure allocation isn't dead code eliminated.
80 public static byte[] tmp;
81
82 public static void main(String[] args) throws Exception {
83 Recording recording = new Recording();
84 recording.enable(EVENT_NAME);
85 recording.start();
86 System.gc();
87 allocate();
88 recording.stop();
89 verifyRecording(recording);
90 int minCount = (int) floor(OBJECTS_TO_ALLOCATE * 0.80);
|