< prev index next >

test/gc/g1/plab/lib/AppPLABResize.java

Print this page




  21  * questions.
  22  */
  23 package gc.g1.plab.lib;
  24 
  25 import jdk.test.lib.Platform;
  26 import sun.hotspot.WhiteBox;
  27 
  28 /**
  29  * This application is part of PLAB Resize test.
  30  * The application allocates objects in 3 iterations:
  31  * 1. Objects of fixed size
  32  * 2. Objects of decreasing size
  33  * 3. Objects of increasing size
  34  * The application doesn't have any assumptions about expected behavior.
  35  * It's supposed to be executed by a test which should set up test parameters (object sizes, number of allocations, etc)
  36  * and VM flags including flags turning GC logging on. The test will then check the produced log.
  37  *
  38  * Expects the following properties to be set:
  39  * - iterations - amount of iteration per cycle.
  40  * - chunk.size - size of objects to be allocated
  41  * - threads - number of gc threads (-XX:ParallelGCThreads) to calculate PLAB sizes.
  42  */
  43 final public class AppPLABResize {
  44 
  45     // Memory to be promoted by PLAB for one thread.
  46     private static final long MEM_ALLOC_WORDS = 32768;
  47     // Defined by properties.
  48     private static final int ITERATIONS = Integer.getInteger("iterations");
  49     private static final long CHUNK = Long.getLong("chunk.size");
  50     private static final int GC_THREADS = Integer.getInteger("threads");
  51 
  52     private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
  53 
  54     /**
  55      * Main method for AppPLABResizing. Application expect for next properties:
  56      * iterations, chunk.size and threads.
  57      *
  58      * @param args
  59      */
  60     public static void main(String[] args) {
  61 
  62         if (ITERATIONS == 0 || CHUNK == 0 || GC_THREADS == 0) {
  63             throw new IllegalArgumentException("Properties should be set");
  64         }
  65 
  66         long wordSize = Platform.is32bit() ? 4l : 8l;
  67         // PLAB size is shared between threads.
  68         long initialMemorySize = wordSize * GC_THREADS * MEM_ALLOC_WORDS;
  69 
  70         // Expect changing memory to half during all iterations.
  71         long memChangeStep = initialMemorySize / 2 / ITERATIONS;
  72 
  73         WHITE_BOX.fullGC();
  74 
  75         // Warm the PLAB. Fill memory ITERATIONS times without changing memory size.
  76         iterateAllocation(initialMemorySize, 0);
  77         // Fill memory ITERATIONS times.
  78         // Initial size is initialMemorySize and step is -memChangeStep
  79         iterateAllocation(initialMemorySize, -memChangeStep);
  80         // Fill memory ITERATIONS times.
  81         // Initial size is memoryAfterChanging, step is memChangeStep.
  82         // Memory size at start should be greater then last size on previous step.
  83         // Last size on previous step is initialMemorySize - memChangeStep*(ITERATIONS - 1)
  84         long memoryAfterChanging = initialMemorySize - memChangeStep * (ITERATIONS - 2);
  85         iterateAllocation(memoryAfterChanging, memChangeStep);
  86     }
  87 
  88     private static void iterateAllocation(long memoryToFill, long change) {


  21  * questions.
  22  */
  23 package gc.g1.plab.lib;
  24 
  25 import jdk.test.lib.Platform;
  26 import sun.hotspot.WhiteBox;
  27 
  28 /**
  29  * This application is part of PLAB Resize test.
  30  * The application allocates objects in 3 iterations:
  31  * 1. Objects of fixed size
  32  * 2. Objects of decreasing size
  33  * 3. Objects of increasing size
  34  * The application doesn't have any assumptions about expected behavior.
  35  * It's supposed to be executed by a test which should set up test parameters (object sizes, number of allocations, etc)
  36  * and VM flags including flags turning GC logging on. The test will then check the produced log.
  37  *
  38  * Expects the following properties to be set:
  39  * - iterations - amount of iteration per cycle.
  40  * - chunk.size - size of objects to be allocated

  41  */
  42 final public class AppPLABResize {
  43 
  44     // Memory to be promoted by PLAB for one thread.
  45     private static final long MEM_ALLOC_WORDS = 32768;
  46     // Defined by properties.
  47     private static final int ITERATIONS = Integer.getInteger("iterations");
  48     private static final long CHUNK = Long.getLong("chunk.size");

  49 
  50     private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
  51 
  52     /**
  53      * Main method for AppPLABResizing. Application expect for next properties:
  54      * iterations, chunk.size and threads.
  55      *
  56      * @param args
  57      */
  58     public static void main(String[] args) {
  59 
  60         if (ITERATIONS == 0 || CHUNK == 0) {
  61             throw new IllegalArgumentException("Properties should be set");
  62         }
  63 
  64         long wordSize = Platform.is32bit() ? 4l : 8l;
  65         // PLAB size is shared between threads.
  66         long initialMemorySize = wordSize * MEM_ALLOC_WORDS;
  67 
  68         // Expect changing memory to half during all iterations.
  69         long memChangeStep = initialMemorySize / 2 / ITERATIONS;
  70 
  71         WHITE_BOX.fullGC();
  72 
  73         // Warm the PLAB. Fill memory ITERATIONS times without changing memory size.
  74         iterateAllocation(initialMemorySize, 0);
  75         // Fill memory ITERATIONS times.
  76         // Initial size is initialMemorySize and step is -memChangeStep
  77         iterateAllocation(initialMemorySize, -memChangeStep);
  78         // Fill memory ITERATIONS times.
  79         // Initial size is memoryAfterChanging, step is memChangeStep.
  80         // Memory size at start should be greater then last size on previous step.
  81         // Last size on previous step is initialMemorySize - memChangeStep*(ITERATIONS - 1)
  82         long memoryAfterChanging = initialMemorySize - memChangeStep * (ITERATIONS - 2);
  83         iterateAllocation(memoryAfterChanging, memChangeStep);
  84     }
  85 
  86     private static void iterateAllocation(long memoryToFill, long change) {
< prev index next >