--- old/test/gc/g1/plab/TestPLABResize.java 2016-01-19 19:38:40.666204116 +0300 +++ new/test/gc/g1/plab/TestPLABResize.java 2016-01-19 19:38:40.574202668 +0300 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -31,7 +31,7 @@ * @build ClassFileInstaller * sun.hotspot.WhiteBox * gc.g1.plab.lib.LogParser - * gc.g1.plab.lib.Storage + * gc.g1.plab.lib.MemoryConsumer * gc.g1.plab.lib.PLABUtils * gc.g1.plab.lib.AppPLABResize * @run main ClassFileInstaller sun.hotspot.WhiteBox @@ -52,7 +52,6 @@ import gc.g1.plab.lib.AppPLABResize; import jdk.test.lib.OutputAnalyzer; -import jdk.test.lib.Pair; import jdk.test.lib.ProcessTools; /** @@ -86,15 +85,10 @@ 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 options = PLABUtils.prepareOptions(PLAB_OPTIONS); - options.addAll(testCase.toOptions()); + List options = PLABUtils.prepareOptions(testCase.toOptions()); options.add(AppPLABResize.class.getName()); OutputAnalyzer out = ProcessTools.executeTestJvm(options.toArray(new String[options.size()])); if (out.getExitValue() != 0) { @@ -114,37 +108,43 @@ */ private static void checkResults(String output, TestCase testCase) { final LogParser log = new LogParser(output); - final List>> entries = log.getEntries(); - final ArrayList 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)); + final Map>> entries = log.getEntries(); - if (plabSizes.isEmpty()) { - System.out.println(output); - throw new RuntimeException("Cannot find desired_plab_sz information for gc_id>" + testCase.iterations); - } + final ArrayList plabSizes = entries.entrySet() + .stream() + .map(item -> { + return item.getValue() + .get(LogParser.ReportType.SURVIVOR_STATS) + .get("desired_plab_sz"); + }) + .collect(Collectors.toCollection(ArrayList::new)); - Long prev = plabSizes.get(0); - // Check that desired plab size is changed during iterations. + // Check that desired plab size was 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) { + List decreasedPlabs = plabSizes.subList(testCase.getIterations(), testCase.getIterations() * 2); + List 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 previout PLAB size should be greater than current. Prev.size: " + prev + " Current size:" + current); + 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!"); } @@ -192,6 +192,7 @@ public List toOptions() { return Arrays.asList("-XX:ParallelGCThreads=" + parGCThreads, "-XX:ParallelGCBufferWastePct=" + wastePct, + "-XX:+ResizePLAB", "-Dthreads=" + parGCThreads, "-Dchunk.size=" + chunkSize, "-Diterations=" + iterations, @@ -208,8 +209,7 @@ 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); + out.println(" Iterations: " + iterations); } /**