< prev index next >

test/jdk/jdk/jfr/event/runtime/TestThreadAllocationEvent.java

Print this page
rev 51054 : imported patch 9000013-aixDisableJFR-requires.patch


  26 package jdk.jfr.event.runtime;
  27 
  28 import static jdk.test.lib.Asserts.assertGreaterThan;
  29 import static jdk.test.lib.Asserts.assertTrue;
  30 
  31 import java.lang.management.ManagementFactory;
  32 import java.time.Duration;
  33 import java.util.Collections;
  34 import java.util.List;
  35 import java.util.Random;
  36 import java.util.concurrent.CountDownLatch;
  37 
  38 import com.sun.management.ThreadMXBean;
  39 
  40 import jdk.jfr.Recording;
  41 import jdk.jfr.consumer.RecordedEvent;
  42 import jdk.jfr.consumer.RecordedThread;
  43 import jdk.test.lib.jfr.EventNames;
  44 import jdk.test.lib.jfr.Events;
  45 
  46 /*
  47  * @test
  48  * @key jfr

  49  * @library /test/lib
  50  * @modules jdk.jfr
  51  *          jdk.management
  52  *
  53  * @run main/othervm -XX:-UseTLAB jdk.jfr.event.runtime.TestThreadAllocationEvent
  54  */
  55 
  56 /**
  57  * The test will create a few threads that will allocate memory for a short time.
  58  * During this time a number of thread_allocation events will be generated.
  59  * The test will verify:
  60  * 1. That number of allocated bytes is not decreasing for a thread.
  61  *  - This assumption is only true when not using TLABs. For this reason the
  62  *    test is run with -XX:-UseTLAB. When using TLABs, the code calculating the
  63  *    allocated bytes is using the current TLAB to do as good of an approximation
  64  *    as possible, but this introduces a race which might double count the current
  65  *    TLAB when it is full and in the middle of being switched out.
  66  * 2. That sum of allocated bytes approximately matches value in ThreadMXBean.
  67  */
  68 public class TestThreadAllocationEvent {




  26 package jdk.jfr.event.runtime;
  27 
  28 import static jdk.test.lib.Asserts.assertGreaterThan;
  29 import static jdk.test.lib.Asserts.assertTrue;
  30 
  31 import java.lang.management.ManagementFactory;
  32 import java.time.Duration;
  33 import java.util.Collections;
  34 import java.util.List;
  35 import java.util.Random;
  36 import java.util.concurrent.CountDownLatch;
  37 
  38 import com.sun.management.ThreadMXBean;
  39 
  40 import jdk.jfr.Recording;
  41 import jdk.jfr.consumer.RecordedEvent;
  42 import jdk.jfr.consumer.RecordedThread;
  43 import jdk.test.lib.jfr.EventNames;
  44 import jdk.test.lib.jfr.Events;
  45 
  46 /**
  47  * @test
  48  * @key jfr
  49  * @requires vm.hasJFR
  50  * @library /test/lib
  51  * @modules jdk.jfr
  52  *          jdk.management
  53  *
  54  * @run main/othervm -XX:-UseTLAB jdk.jfr.event.runtime.TestThreadAllocationEvent
  55  */
  56 
  57 /**
  58  * The test will create a few threads that will allocate memory for a short time.
  59  * During this time a number of thread_allocation events will be generated.
  60  * The test will verify:
  61  * 1. That number of allocated bytes is not decreasing for a thread.
  62  *  - This assumption is only true when not using TLABs. For this reason the
  63  *    test is run with -XX:-UseTLAB. When using TLABs, the code calculating the
  64  *    allocated bytes is using the current TLAB to do as good of an approximation
  65  *    as possible, but this introduces a race which might double count the current
  66  *    TLAB when it is full and in the middle of being switched out.
  67  * 2. That sum of allocated bytes approximately matches value in ThreadMXBean.
  68  */
  69 public class TestThreadAllocationEvent {


< prev index next >