/* * 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. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
/* * @test TestIHOPErgo * @bug 8148397 * @key stress * @summary Test checks that behavior of Adaptive and Static IHOP at concurrent cycle initiation * @requires vm.gc.G1 * @requires !vm.flightRecorder * @requires vm.opt.ExplicitGCInvokesConcurrent != true * @requires vm.opt.MaxGCPauseMillis == "null" * @library /test/lib / * @modules java.base/jdk.internal.misc * @modules java.management * @run driver/timeout=480 gc.g1.ihop.TestIHOPErgo
*/ package gc.g1.ihop;
/** * The test starts the AppIHOP multiple times varying settings of MaxHeapSize. * The test parses GC log from AppIHOP to check: * - occupancy is not less than threshold for Adaptive and Static IHOP at * concurrent cycle initiation * - Adaptive IHOP prediction was started during AppIHOP executing * - log contains ergonomic messages in log
*/ publicclass TestIHOPErgo {
// Common GC tune and logging options for test. privatefinalstatic String[] COMMON_OPTIONS = { "-XX:+UnlockExperimentalVMOptions", "-XX:G1MixedGCLiveThresholdPercent=100", "-XX:G1HeapWastePercent=0", "-XX:MaxGCPauseMillis=30000", "-XX:G1MixedGCCountTarget=1", "-XX:+UseG1GC", "-XX:G1HeapRegionSize=1m", "-XX:+G1UseAdaptiveIHOP", "-Xlog:gc+ihop=debug,gc+ihop+ergo=debug,gc+ergo=debug", "-XX:+AlwaysTenure", "-XX:G1AdaptiveIHOPNumInitialSamples=1", "-XX:InitiatingHeapOccupancyPercent=30"
};
Collections.addAll(options, COMMON_OPTIONS);
options.add(AppIHOP.class.getName());
OutputAnalyzer out = executeTest(options);
// Checks that log contains message which indicates that IHOP prediction is active if (isIhopAdaptive) {
IhopUtils.checkAdaptiveIHOPWasActivated(out);
} // Checks that log contains messages which indicates that VM initiates/checks heap occupancy // and tries to start concurrent cycle.
IhopUtils.checkErgoMessagesExist(out);
// Checks threshold and occupancy values
IhopUtils.checkIhopLogValues(out);
}
privatestatic OutputAnalyzer executeTest(List<String> options) throws Throwable, RuntimeException {
OutputAnalyzer out = ProcessTools.executeTestJvm(options); if (out.getExitValue() != 0) {
System.out.println(out.getOutput()); thrownew RuntimeException("AppIHOP failed with exit code" + out.getExitValue());
} return out;
}
/** * The AppIHOP fills 60% of heap and allocates and frees 30% of existing * heap 'iterations' times to achieve IHOP activation. To be executed in * separate VM. Expected properties: * heap.size - heap size which is used to calculate amount of memory * to be allocated and freed * sleep.time - short pause between filling each MB
*/ publicstaticclass AppIHOP {
publicfinalstatic LinkedList<Object> GARBAGE = new LinkedList<>();
privatefinalint ITERATIONS = 10; privatefinalint OBJECT_SIZE = 100000; // 60% of the heap will be filled before test cycles. // 30% of the heap will be filled and freed during test cycle. privatefinallong HEAP_PREALLOC_PCT = 60; privatefinallong HEAP_ALLOC_PCT = 30; privatefinallong HEAP_SIZE; // Amount of memory to be allocated before iterations start privatefinallong HEAP_PREALLOC_SIZE; // Amount of memory to be allocated and freed during iterations privatefinallong HEAP_ALLOC_SIZE; privatefinalint SLEEP_TIME;
publicstaticvoid main(String[] args) throws InterruptedException { new AppIHOP().start();
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.