< prev index next >

test/gc/g1/plab/TestPLABResize.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.
*** 29,39 **** * @library /testlibrary /../../test/lib / * @modules java.management * @build ClassFileInstaller * sun.hotspot.WhiteBox * gc.g1.plab.lib.LogParser ! * gc.g1.plab.lib.Storage * gc.g1.plab.lib.PLABUtils * gc.g1.plab.lib.AppPLABResize * @run main ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission * @run main gc.g1.plab.TestPLABResize --- 29,39 ---- * @library /testlibrary /../../test/lib / * @modules java.management * @build ClassFileInstaller * sun.hotspot.WhiteBox * gc.g1.plab.lib.LogParser ! * gc.g1.plab.lib.MemoryConsumer * gc.g1.plab.lib.PLABUtils * gc.g1.plab.lib.AppPLABResize * @run main ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission * @run main gc.g1.plab.TestPLABResize
*** 50,60 **** import gc.g1.plab.lib.LogParser; import gc.g1.plab.lib.PLABUtils; import gc.g1.plab.lib.AppPLABResize; import jdk.test.lib.OutputAnalyzer; - import jdk.test.lib.Pair; import jdk.test.lib.ProcessTools; /** * Test for PLAB resizing. */ --- 50,59 ----
*** 84,102 **** new TestCase(WASTE_PCT_HIGH, OBJECT_SIZE_SMALL, GC_NUM_HIGH, ITERATIONS_MEDIUM), new TestCase(WASTE_PCT_HIGH, OBJECT_SIZE_MEDIUM, GC_NUM_SMALL, ITERATIONS_SMALL), new TestCase(WASTE_PCT_HIGH, OBJECT_SIZE_HIGH, GC_NUM_MEDIUM, ITERATIONS_HIGH) }; - private static final String[] PLAB_OPTIONS = { - "-XX:+ResizePLAB" - }; - public static void main(String[] args) throws Throwable { for (TestCase testCase : TEST_CASES) { testCase.print(System.out); ! List<String> options = PLABUtils.prepareOptions(PLAB_OPTIONS); ! options.addAll(testCase.toOptions()); options.add(AppPLABResize.class.getName()); OutputAnalyzer out = ProcessTools.executeTestJvm(options.toArray(new String[options.size()])); if (out.getExitValue() != 0) { System.out.println(out.getOutput()); throw new RuntimeException("Exit code is not 0"); --- 83,96 ---- new TestCase(WASTE_PCT_HIGH, OBJECT_SIZE_SMALL, GC_NUM_HIGH, ITERATIONS_MEDIUM), new TestCase(WASTE_PCT_HIGH, OBJECT_SIZE_MEDIUM, GC_NUM_SMALL, ITERATIONS_SMALL), new TestCase(WASTE_PCT_HIGH, OBJECT_SIZE_HIGH, GC_NUM_MEDIUM, ITERATIONS_HIGH) }; public static void main(String[] args) throws Throwable { for (TestCase testCase : TEST_CASES) { testCase.print(System.out); ! List<String> options = PLABUtils.prepareOptions(testCase.toOptions()); options.add(AppPLABResize.class.getName()); OutputAnalyzer out = ProcessTools.executeTestJvm(options.toArray(new String[options.size()])); if (out.getExitValue() != 0) { System.out.println(out.getOutput()); throw new RuntimeException("Exit code is not 0");
*** 112,152 **** * @param output - VM output * @param testCase */ private static void checkResults(String output, TestCase testCase) { final LogParser log = new LogParser(output); ! final List<Pair<LogParser.ReportType, ? extends Map<String, Long>>> entries = log.getEntries(); ! final ArrayList<Long> plabSizes = entries.stream() ! .filter(p -> p.first == LogParser.ReportType.SURVIVOR_STATS) ! .map(p -> p.second) ! // We do not need first iterations - it is 'warm' phase of allocation. ! .filter(mapEntries -> mapEntries.get(LogParser.GC_ID) > testCase.iterations) ! .map(items -> items.get("desired_plab_sz")) ! .collect(Collectors.toCollection(ArrayList::new)); ! if (plabSizes.isEmpty()) { ! System.out.println(output); ! throw new RuntimeException("Cannot find desired_plab_sz information for gc_id>" + testCase.iterations); ! } ! Long prev = plabSizes.get(0); ! // Check that desired plab size is changed during iterations. // It should decrease during first half of iterations // and increase after. ! for (int index = 1; index < plabSizes.size(); ++index) { ! Long current = plabSizes.get(index); ! if (index < testCase.getIterations()) { if (prev < current) { System.out.println(output); ! throw new RuntimeException("Test failed! Expect that previout PLAB size should be less than current. Prev.size: " + prev + " Current size:" + current); } ! } else if (prev > current) { System.out.println(output); ! throw new RuntimeException("Test failed! Expect that previout PLAB size should be greater than current. Prev.size: " + prev + " Current size:" + current); } prev = current; } System.out.println("Test passed!"); } /** * Description of one test case. --- 106,152 ---- * @param output - VM output * @param testCase */ private static void checkResults(String output, TestCase testCase) { final LogParser log = new LogParser(output); ! final Map<Long, Map<LogParser.ReportType, Map<String, Long>>> entries = log.getEntries(); ! final ArrayList<Long> plabSizes = entries.entrySet() ! .stream() ! .map(item -> { ! return item.getValue() ! .get(LogParser.ReportType.SURVIVOR_STATS) ! .get("desired_plab_sz"); ! }) ! .collect(Collectors.toCollection(ArrayList::new)); ! // Check that desired plab size was changed during iterations. // It should decrease during first half of iterations // and increase after. ! List<Long> decreasedPlabs = plabSizes.subList(testCase.getIterations(), testCase.getIterations() * 2); ! List<Long> increasedPlabs = plabSizes.subList(testCase.getIterations() * 2, testCase.getIterations() * 3); ! ! Long prev = decreasedPlabs.get(0); ! for (int index = 1; index < decreasedPlabs.size(); ++index) { ! Long current = decreasedPlabs.get(index); if (prev < current) { System.out.println(output); ! throw new RuntimeException("Test failed! Expect that previous PLAB size should be greater than current. Prev.size: " + prev + " Current size:" + current); ! } ! prev = current; } ! ! prev = increasedPlabs.get(0); ! for (int index = 1; index < increasedPlabs.size(); ++index) { ! Long current = increasedPlabs.get(index); ! if (prev > current) { System.out.println(output); ! throw new RuntimeException("Test failed! Expect that previous PLAB size should be less than current. Prev.size: " + prev + " Current size:" + current); } prev = current; } + System.out.println("Test passed!"); } /** * Description of one test case.
*** 190,199 **** --- 190,200 ---- * List of options */ public List<String> toOptions() { return Arrays.asList("-XX:ParallelGCThreads=" + parGCThreads, "-XX:ParallelGCBufferWastePct=" + wastePct, + "-XX:+ResizePLAB", "-Dthreads=" + parGCThreads, "-Dchunk.size=" + chunkSize, "-Diterations=" + iterations, "-XX:NewSize=16m", "-XX:MaxNewSize=16m"
*** 206,217 **** public void print(PrintStream out) { out.println("Test case details:"); out.println(" Parallel GC buffer waste pct : " + wastePct); out.println(" Chunk size : " + chunkSize); out.println(" Parallel GC threads : " + parGCThreads); ! out.println(" Iterations per one allocation part : " + iterations); ! out.println(" All iteration of allocations : " + iterations * 3); } /** * @return iterations */ --- 207,217 ---- public void print(PrintStream out) { out.println("Test case details:"); out.println(" Parallel GC buffer waste pct : " + wastePct); out.println(" Chunk size : " + chunkSize); out.println(" Parallel GC threads : " + parGCThreads); ! out.println(" Iterations: " + iterations); } /** * @return iterations */
< prev index next >