--- old/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp 2014-12-11 16:32:01.654614498 -0500 +++ new/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp 2014-12-11 16:32:01.102582776 -0500 @@ -2559,12 +2559,12 @@ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, \ x } -// Initialize with default setting of CMSParPromoteBlocksToClaim, _not_ -// OldPLABSize, whose static default is different; if overridden at the +// Initialize with default setting for CMS, _not_ +// generic OldPLABSize, whose static default is different; if overridden at the // command-line, this will get reinitialized via a call to // modify_initialization() below. AdaptiveWeightedAverage CFLS_LAB::_blocks_to_claim[] = - VECTOR_257(AdaptiveWeightedAverage(OldPLABWeight, (float)CMSParPromoteBlocksToClaim)); + VECTOR_257(AdaptiveWeightedAverage(OldPLABWeight, (float)CFLS_LAB::_default_dynamic_old_plab_size)); size_t CFLS_LAB::_global_num_blocks[] = VECTOR_257(0); uint CFLS_LAB::_global_num_workers[] = VECTOR_257(0); --- old/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp 2014-12-11 16:32:03.282708048 -0500 +++ new/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp 2014-12-11 16:32:02.822681616 -0500 @@ -690,6 +690,9 @@ void get_from_global_pool(size_t word_sz, AdaptiveFreeList* fl); public: + static const int _default_dynamic_old_plab_size = 16; + static const int _default_static_old_plab_size = 50; + CFLS_LAB(CompactibleFreeListSpace* cfls); // Allocate and return a block of the given size, or else return NULL. --- old/src/share/vm/runtime/arguments.cpp 2014-12-11 16:32:04.778794015 -0500 +++ new/src/share/vm/runtime/arguments.cpp 2014-12-11 16:32:04.314767353 -0500 @@ -925,9 +925,9 @@ "Warning: support for %s was removed in %s\n", fuzzy_matched->_name, version); - } } } + } // allow for commandline "commenting out" options like -XX:#+Verbose return arg[0] == '#'; @@ -1312,7 +1312,7 @@ MIN2(max_heap/(NewRatio+1), ScaleForWordSize(young_gen_per_worker * parallel_gc_threads)); size_t preferred_max_new_size = align_size_up(preferred_max_new_size_unaligned, os::vm_page_size()); - + // Unless explicitly requested otherwise, size young gen // for "short" pauses ~ CMSYoungGenPerWorker*ParallelGCThreads @@ -1382,41 +1382,24 @@ if (FLAG_IS_DEFAULT(SurvivorRatio) && MaxTenuringThreshold == 0) { FLAG_SET_ERGO(uintx, SurvivorRatio, MAX2((uintx)1024, SurvivorRatio)); } - // If OldPLABSize is set and CMSParPromoteBlocksToClaim is not, - // set CMSParPromoteBlocksToClaim equal to OldPLABSize. - // This is done in order to make ParNew+CMS configuration to work - // with YoungPLABSize and OldPLABSize options. - // See CR 6362902. - if (!FLAG_IS_DEFAULT(OldPLABSize)) { - if (FLAG_IS_DEFAULT(CMSParPromoteBlocksToClaim)) { - // OldPLABSize is not the default value but CMSParPromoteBlocksToClaim - // is. In this situation let CMSParPromoteBlocksToClaim follow - // the value (either from the command line or ergonomics) of - // OldPLABSize. Following OldPLABSize is an ergonomics decision. - FLAG_SET_ERGO(uintx, CMSParPromoteBlocksToClaim, OldPLABSize); + + // OldPLABSize is interpreted in CMS as not the size of the PLAB in words, + // but rather the number of free blocks of a given size that are used when + // replenishing the local per-worker free list caches. + if (FLAG_IS_DEFAULT(OldPLABSize)) { + if (!FLAG_IS_DEFAULT(ResizeOldPLAB) && !ResizeOldPLAB) { + // OldPLAB sizing manually turned off: Use a larger default setting, + // unless it was manually specified. This is because a too-low value + // will slow down scavenges. + FLAG_SET_ERGO(uintx, OldPLABSize, CFLS_LAB::_default_static_old_plab_size); // default value before 6631166 } else { - // OldPLABSize and CMSParPromoteBlocksToClaim are both set. - // CMSParPromoteBlocksToClaim is a collector-specific flag, so - // we'll let it to take precedence. - jio_fprintf(defaultStream::error_stream(), - "Both OldPLABSize and CMSParPromoteBlocksToClaim" - " options are specified for the CMS collector." - " CMSParPromoteBlocksToClaim will take precedence.\n"); - } - } - if (!FLAG_IS_DEFAULT(ResizeOldPLAB) && !ResizeOldPLAB) { - // OldPLAB sizing manually turned off: Use a larger default setting, - // unless it was manually specified. This is because a too-low value - // will slow down scavenges. - if (FLAG_IS_DEFAULT(CMSParPromoteBlocksToClaim)) { - FLAG_SET_ERGO(uintx, CMSParPromoteBlocksToClaim, 50); // default value before 6631166 + FLAG_SET_DEFAULT(OldPLABSize, CFLS_LAB::_default_dynamic_old_plab_size); // old CMSParPromoteBlocksToClaim default } } - // Overwrite OldPLABSize which is the variable we will internally use everywhere. - FLAG_SET_ERGO(uintx, OldPLABSize, CMSParPromoteBlocksToClaim); + // If either of the static initialization defaults have changed, note this // modification. - if (!FLAG_IS_DEFAULT(CMSParPromoteBlocksToClaim) || !FLAG_IS_DEFAULT(OldPLABWeight)) { + if (!FLAG_IS_DEFAULT(OldPLABSize) || !FLAG_IS_DEFAULT(OldPLABWeight)) { CFLS_LAB::modify_initialization(OldPLABSize, OldPLABWeight); } if (PrintGCDetails && Verbose) { @@ -3222,52 +3205,6 @@ FLAG_SET_CMDLINE(bool, NeverTenure, false); FLAG_SET_CMDLINE(bool, AlwaysTenure, false); } - } else if (match_option(option, "-XX:+CMSPermGenSweepingEnabled") || - match_option(option, "-XX:-CMSPermGenSweepingEnabled")) { - jio_fprintf(defaultStream::error_stream(), - "Please use CMSClassUnloadingEnabled in place of " - "CMSPermGenSweepingEnabled in the future\n"); - } else if (match_option(option, "-XX:+UseGCTimeLimit")) { - FLAG_SET_CMDLINE(bool, UseGCOverheadLimit, true); - jio_fprintf(defaultStream::error_stream(), - "Please use -XX:+UseGCOverheadLimit in place of " - "-XX:+UseGCTimeLimit in the future\n"); - } else if (match_option(option, "-XX:-UseGCTimeLimit")) { - FLAG_SET_CMDLINE(bool, UseGCOverheadLimit, false); - jio_fprintf(defaultStream::error_stream(), - "Please use -XX:-UseGCOverheadLimit in place of " - "-XX:-UseGCTimeLimit in the future\n"); - // The TLE options are for compatibility with 1.3 and will be - // removed without notice in a future release. These options - // are not to be documented. - } else if (match_option(option, "-XX:MaxTLERatio=", &tail)) { - // No longer used. - } else if (match_option(option, "-XX:+ResizeTLE")) { - FLAG_SET_CMDLINE(bool, ResizeTLAB, true); - } else if (match_option(option, "-XX:-ResizeTLE")) { - FLAG_SET_CMDLINE(bool, ResizeTLAB, false); - } else if (match_option(option, "-XX:+PrintTLE")) { - FLAG_SET_CMDLINE(bool, PrintTLAB, true); - } else if (match_option(option, "-XX:-PrintTLE")) { - FLAG_SET_CMDLINE(bool, PrintTLAB, false); - } else if (match_option(option, "-XX:TLEFragmentationRatio=", &tail)) { - // No longer used. - } else if (match_option(option, "-XX:TLESize=", &tail)) { - julong long_tlab_size = 0; - ArgsRange errcode = parse_memory_size(tail, &long_tlab_size, 1); - if (errcode != arg_in_range) { - jio_fprintf(defaultStream::error_stream(), - "Invalid TLAB size: %s\n", option->optionString); - describe_range_error(errcode); - return JNI_EINVAL; - } - FLAG_SET_CMDLINE(uintx, TLABSize, long_tlab_size); - } else if (match_option(option, "-XX:TLEThreadRatio=", &tail)) { - // No longer used. - } else if (match_option(option, "-XX:+UseTLE")) { - FLAG_SET_CMDLINE(bool, UseTLAB, true); - } else if (match_option(option, "-XX:-UseTLE")) { - FLAG_SET_CMDLINE(bool, UseTLAB, false); } else if (match_option(option, "-XX:+DisplayVMOutputToStderr")) { FLAG_SET_CMDLINE(bool, DisplayVMOutputToStdout, false); FLAG_SET_CMDLINE(bool, DisplayVMOutputToStderr, true); @@ -3291,44 +3228,6 @@ // disable scavenge before parallel mark-compact FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false); #endif - } else if (match_option(option, "-XX:CMSParPromoteBlocksToClaim=", &tail)) { - julong cms_blocks_to_claim = (julong)atol(tail); - FLAG_SET_CMDLINE(uintx, CMSParPromoteBlocksToClaim, cms_blocks_to_claim); - jio_fprintf(defaultStream::error_stream(), - "Please use -XX:OldPLABSize in place of " - "-XX:CMSParPromoteBlocksToClaim in the future\n"); - } else if (match_option(option, "-XX:ParCMSPromoteBlocksToClaim=", &tail)) { - julong cms_blocks_to_claim = (julong)atol(tail); - FLAG_SET_CMDLINE(uintx, CMSParPromoteBlocksToClaim, cms_blocks_to_claim); - jio_fprintf(defaultStream::error_stream(), - "Please use -XX:OldPLABSize in place of " - "-XX:ParCMSPromoteBlocksToClaim in the future\n"); - } else if (match_option(option, "-XX:ParallelGCOldGenAllocBufferSize=", &tail)) { - julong old_plab_size = 0; - ArgsRange errcode = parse_memory_size(tail, &old_plab_size, 1); - if (errcode != arg_in_range) { - jio_fprintf(defaultStream::error_stream(), - "Invalid old PLAB size: %s\n", option->optionString); - describe_range_error(errcode); - return JNI_EINVAL; - } - FLAG_SET_CMDLINE(uintx, OldPLABSize, old_plab_size); - jio_fprintf(defaultStream::error_stream(), - "Please use -XX:OldPLABSize in place of " - "-XX:ParallelGCOldGenAllocBufferSize in the future\n"); - } else if (match_option(option, "-XX:ParallelGCToSpaceAllocBufferSize=", &tail)) { - julong young_plab_size = 0; - ArgsRange errcode = parse_memory_size(tail, &young_plab_size, 1); - if (errcode != arg_in_range) { - jio_fprintf(defaultStream::error_stream(), - "Invalid young PLAB size: %s\n", option->optionString); - describe_range_error(errcode); - return JNI_EINVAL; - } - FLAG_SET_CMDLINE(uintx, YoungPLABSize, young_plab_size); - jio_fprintf(defaultStream::error_stream(), - "Please use -XX:YoungPLABSize in place of " - "-XX:ParallelGCToSpaceAllocBufferSize in the future\n"); } else if (match_option(option, "-XX:CMSMarkStackSize=", &tail) || match_option(option, "-XX:G1MarkStackSize=", &tail)) { julong stack_size = 0; @@ -3339,6 +3238,9 @@ describe_range_error(errcode); return JNI_EINVAL; } + jio_fprintf(defaultStream::error_stream(), + "Please use -XX:MarkStackSize in place of " + "-XX:CMSMarkStackSize or -XX:G1MarkStackSize in the future\n"); FLAG_SET_CMDLINE(uintx, MarkStackSize, stack_size); } else if (match_option(option, "-XX:CMSMarkStackSizeMax=", &tail)) { julong max_stack_size = 0; @@ -3350,6 +3252,9 @@ describe_range_error(errcode); return JNI_EINVAL; } + jio_fprintf(defaultStream::error_stream(), + "Please use -XX:MarkStackSizeMax in place of " + "-XX:CMSMarkStackSizeMax in the future\n"); FLAG_SET_CMDLINE(uintx, MarkStackSizeMax, max_stack_size); } else if (match_option(option, "-XX:ParallelMarkingThreads=", &tail) || match_option(option, "-XX:ParallelCMSThreads=", &tail)) { @@ -3359,6 +3264,9 @@ "Invalid concurrent threads: %s\n", option->optionString); return JNI_EINVAL; } + jio_fprintf(defaultStream::error_stream(), + "Please use -XX:ConcGCThreads in place of " + "-XX:ParallelMarkingThreads or -XX:ParallelCMSThreads in the future\n"); FLAG_SET_CMDLINE(uintx, ConcGCThreads, conc_threads); } else if (match_option(option, "-XX:MaxDirectMemorySize=", &tail)) { julong max_direct_memory_size = 0; --- old/src/share/vm/runtime/globals.hpp 2014-12-11 16:32:06.354884580 -0500 +++ new/src/share/vm/runtime/globals.hpp 2014-12-11 16:32:05.882857457 -0500 @@ -1472,7 +1472,8 @@ "Size of young gen promotion LAB's (in HeapWords)") \ \ product(uintx, OldPLABSize, 1024, \ - "Size of old gen promotion LAB's (in HeapWords)") \ + "Size of old gen promotion LAB's (in HeapWords), or Number \ + of blocks to attempt to claim when refilling CMS LAB's") \ \ product(uintx, GCTaskTimeStampEntries, 200, \ "Number of time stamp entries per gc worker thread") \ @@ -1583,14 +1584,10 @@ "The number of cards in each chunk of the parallel chunks used " \ "during card table scanning") \ \ - product(uintx, CMSParPromoteBlocksToClaim, 16, \ - "Number of blocks to attempt to claim when refilling CMS LAB's " \ - "for parallel GC") \ - \ product(uintx, OldPLABWeight, 50, \ "Percentage (0-100) used to weight the current sample when " \ "computing exponentially decaying average for resizing " \ - "CMSParPromoteBlocksToClaim") \ + "OldPLABSize") \ \ product(bool, ResizeOldPLAB, true, \ "Dynamically resize (old gen) promotion LAB's") \ --- /dev/null 2014-09-29 03:28:39.162223999 -0400 +++ new/test/runtime/CommandLine/VMOptionsLifecycle.java 2014-12-11 16:32:07.410945260 -0500 @@ -0,0 +1,221 @@ +/* + * Copyright (c) 2014, 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 + * @bug 8061611 + * @summary Test that various options have been removed, or are deprecated, or are aliased. Can be extended to test other options as needed. + * @library /testlibrary + */ +import java.util.ArrayList; +import com.oracle.java.testlibrary.*; + +public class VMOptionsLifecycle { + + private static final String PRINT_FLAGS_FINAL_FORMAT = "%s\\s*:?=\\s*%s"; + + public static final String[] REMOVED_OPTIONS = { + "CMSParPromoteBlocksToClaim", + "ParCMSPromoteBlocksToClaim", + "ParallelGCOldGenAllocBufferSize", + "ParallelGCToSpaceAllocBufferSize", + "UseGCTimeLimit", + "CMSPermGenSweepingEnabled", + "MaxTLERatio", + "ResizeTLE", + "PrintTLE", + "TLEFragmentationRatio", + "TLESize", + "TLEThreadRatio", + "UseTLE" + }; + + /** + * each entry is {[0]: alias name, [1]: alias target, [2]: value to set + * (+/-/n)} + */ + public static final String[][] UNDEPRECATED_ALIAS_OPTIONS = { //undeprecated aliases: + // --- none --- + }; + + /** + * each entry is {[0]: alias name, [1]: alias target, [2]: value to set + * (+/-/n)}. n can be any valid value for the option. + */ + public static final String[][] DEPRECATED_ALIAS_OPTIONS = { + {"CMSMarkStackSizeMax", "MarkStackSizeMax", "1032"}, + {"CMSMarkStackSize", "MarkStackSize", "1032"}, + {"G1MarkStackSize", "MarkStackSize", "1032"}, + {"ParallelMarkingThreads", "ConcGCThreads", "77"}, + {"ParallelCMSThreads", "ConcGCThreads", "77"} + }; + + public static final String[][] ALIAS_OPTIONS; // = UNDEPRECATED_ALIAS_OPTIONS + DEPRECATED_ALIAS_OPTIONS + + /** + * each entry is {[0]: option name, [1]: value to set (+/-/n)} + */ + public static final String[][] DEPRECATED_SIMPLE_OPTIONS = { //deprecated options: + // --- none --- + }; + + public static final String[][] DEPRECATED_OPTIONS; // = DEPRECATED_SIMPLE_OPTIONS + DEPRECATED_ALIAS_OPTIONS + + static String[][] concatOptions(String[][] a, String[][] b) { + String[][] result = new String[a.length + b.length][]; + System.arraycopy(a, 0, result, 0, a.length); + System.arraycopy(b, 0, result, a.length, b.length); + return result; + } + + static { + ALIAS_OPTIONS = concatOptions(UNDEPRECATED_ALIAS_OPTIONS, DEPRECATED_ALIAS_OPTIONS); + DEPRECATED_OPTIONS = concatOptions(DEPRECATED_SIMPLE_OPTIONS, DEPRECATED_ALIAS_OPTIONS); + } + + static void testRemoved(String option, boolean normalTest) throws Throwable { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+" + option, "-version"); + + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + + if (!normalTest) { + output.shouldNotContain("Unrecognized VM option '" + option + "'"); + output.shouldHaveExitValue(0); + } else { + output.shouldContain("Unrecognized VM option '" + option + "'"); + output.shouldHaveExitValue(1); + } +// System.out.println("=== output ==="); +// System.out.print(output.getOutput()); + } + + /** + * Turn the optionInfo into a legal -XX: command line argument. + * @param optionInfo + * @return + */ + static String makeOptionArg(String[] optionInfo) { + String value = optionInfo[optionInfo.length-1]; + if (value.equals("+")) { + return "-XX:+" + optionInfo[0]; + } else if (value.equals("-")) { + return "-XX:-" + optionInfo[0]; + } else { + return "-XX:" + optionInfo[0] + "=" + value; + } + } + + /** + * Turn the optionInfo into pattern that might match "-XX:+PrintFlagsFinal output. + * @param optionInfo + * @return + */ + static String makeOptionFinalValue(String option, String value) { + if (value.equals("+")) { + value = "true"; + } else if (value.equals("-")) { + value = "false"; + } + return String.format(PRINT_FLAGS_FINAL_FORMAT, + option, value); + } + + /** + * Test all aliased options in one jvm exec. + */ + static void testAliases(String[][] optionInfo, boolean normalTest) throws Throwable { + ArrayList args = new ArrayList<>(); + // construct args: + for (String[] alias: optionInfo) { + args.add(makeOptionArg(alias)); + } + args.add("-XX:+PrintFlagsFinal"); + args.add("-version"); + + // start vm: + String[] args_array = new String[args.size()]; + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args.toArray(args_array)); + + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + + // check option values: + output.shouldHaveExitValue(0); + for (String[] alias: optionInfo) { + String match = makeOptionFinalValue(alias[1], alias[2]); + if (normalTest) { + output.shouldMatch(match); + } else { + output.shouldNotMatch(match); + } + } + } + + /** + * Test all deprecated options in one jvm exec. + */ + static void testDeprecated(String[][] optionInfo, boolean normalTest) throws Throwable { + ArrayList args = new ArrayList<>(); + // construct args: + for (String[] deprecated: optionInfo) { + args.add(makeOptionArg(deprecated)); + } + args.add("-version"); + + // start vm: + String[] args_array = new String[args.size()]; + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args.toArray(args_array)); + + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + + // check for option deprecation messages: + output.shouldHaveExitValue(0); + for (String[] deprecated: optionInfo) { + // Searching precisely for deprecation warnings is too hard at the moment. + // There is no standard format. For now, just search for the option name in the output, + // which should only be printed if there was some deprecation warning. + String realOpt = (deprecated.length == 2) ? deprecated[0] : deprecated[1]; + String match = realOpt; + if (normalTest) { + output.shouldMatch(match); + } else { + output.shouldNotMatch(match); + } + } + } + + public static void main(String[] args) throws Throwable { + testRemoved("UseTLAB", false); // Test the test. UseTLAB has NOT been removed. + + for (String str: REMOVED_OPTIONS) { + testRemoved(str, true); // Test should fail for each removed option. + } + + String[][] testTestAliases = {{"MarkStackSizeMax", "CMSMarkStackSizeMax", "1032"}}; + testAliases(testTestAliases, false); // MarkStackSizeMax is NOT an alias for CMSMarkStackSizeMax. + testAliases(ALIAS_OPTIONS, true); + + String[][] testTestDeprecated = {{"UseTLAB", "+"}}; + testDeprecated(testTestDeprecated, false); // Test the test. The output should NOT mention "UseTLAB" at all. + testDeprecated(DEPRECATED_OPTIONS, true); // Make sure that each deprecated option is mentioned in the output. + } +}