< prev index next >

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

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 24,50 **** import jdk.test.lib.Platform; import sun.hotspot.WhiteBox; /** ! * An simple application a part of PLAB Resize test to be executed in the VM under tests. * The application allocates objects in 3 iterations: * 1. Objects of fixed size * 2. Objects of decreasing size * 3. Objects of increasing size * The application doesn't have any assumptions about expected behavior. ! * It's supposed to be executed a test which suppose to setup test parameters (object sizes, number of allocations, etc) * and VM flags including flags turning GC logging on. The test will then check the produced log. */ final public class AppPLABResize { // Memory to be promoted by PLAB for one thread. private static final long MEM_ALLOC_WORDS = 32768; // Defined by properties. private static final int ITERATIONS = Integer.getInteger("iterations"); private static final long CHUNK = Long.getLong("chunk.size"); ! private static final int THREADS = Integer.getInteger("threads"); private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); /** * Main method for AppPLABResizing. Application expect for next properties: --- 24,55 ---- import jdk.test.lib.Platform; import sun.hotspot.WhiteBox; /** ! * This application is part of PLAB Resize test. * The application allocates objects in 3 iterations: * 1. Objects of fixed size * 2. Objects of decreasing size * 3. Objects of increasing size * The application doesn't have any assumptions about expected behavior. ! * It's supposed to be executed by a test which should set up test parameters (object sizes, number of allocations, etc) * and VM flags including flags turning GC logging on. The test will then check the produced log. + * + * Expects the following properties to be set: + * - iterations - amount of iteration per cycle. + * - chunk.size - size of objects to be allocated + * - threads - number of gc threads (-XX:ParallelGCThreads) to calculate PLAB sizes. */ final public class AppPLABResize { // Memory to be promoted by PLAB for one thread. private static final long MEM_ALLOC_WORDS = 32768; // Defined by properties. private static final int ITERATIONS = Integer.getInteger("iterations"); private static final long CHUNK = Long.getLong("chunk.size"); ! private static final int GC_THREADS = Integer.getInteger("threads"); private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); /** * Main method for AppPLABResizing. Application expect for next properties:
*** 52,68 **** * * @param args */ public static void main(String[] args) { ! if (ITERATIONS == 0 || CHUNK == 0 || THREADS == 0) { throw new IllegalArgumentException("Properties should be set"); } long wordSize = Platform.is32bit() ? 4l : 8l; // PLAB size is shared between threads. ! long initialMemorySize = wordSize * THREADS * MEM_ALLOC_WORDS; // Expect changing memory to half during all iterations. long memChangeStep = initialMemorySize / 2 / ITERATIONS; WHITE_BOX.fullGC(); --- 57,73 ---- * * @param args */ public static void main(String[] args) { ! if (ITERATIONS == 0 || CHUNK == 0 || GC_THREADS == 0) { throw new IllegalArgumentException("Properties should be set"); } long wordSize = Platform.is32bit() ? 4l : 8l; // PLAB size is shared between threads. ! long initialMemorySize = wordSize * GC_THREADS * MEM_ALLOC_WORDS; // Expect changing memory to half during all iterations. long memChangeStep = initialMemorySize / 2 / ITERATIONS; WHITE_BOX.fullGC();
*** 89,110 **** } long currentMemToFill = memoryToFill; for (int iteration = 0; iteration < ITERATIONS; ++iteration) { ! Storage storage = new Storage(items); ! allocateYoung(storage, currentMemToFill); // Promote all objects to survivor WHITE_BOX.youngGC(); storage.clear(); currentMemToFill += change; } } - private static void allocateYoung(Storage storage, long memoryToFill) { - long allocated = 0; - while (allocated < memoryToFill) { - storage.store(new byte[(int) CHUNK]); - allocated += CHUNK; - } - } } --- 94,108 ---- } long currentMemToFill = memoryToFill; for (int iteration = 0; iteration < ITERATIONS; ++iteration) { ! MemoryConsumer storage = new MemoryConsumer(items, (int) CHUNK); ! storage.consume(currentMemToFill); // Promote all objects to survivor WHITE_BOX.youngGC(); storage.clear(); currentMemToFill += change; } } }
< prev index next >